Re: [opensuse] Need some help with a script




----- Original Message ----- From: "Randall R Schulz" <rschulz@xxxxxxxxx>
To: <opensuse@xxxxxxxxxxxx>
Sent: Thursday, February 05, 2009 5:46 PM
Subject: Re: [opensuse] Need some help with a script


On Thursday February 5 2009, nordi wrote:
Rikard Johnels wrote:
>> while read x; do
>
> Cant get this to work at all.
> It starts, but just sits there doing nothing.

OK, should have added that you need to run "cat the_file |
./my_script", just as with my sed program. The "read x" reads from
stdin, and will wait forever if it has to.

While that works, we really shouldn't be encouraging such roundabout
ways of redirecting a program's standard input. That is what the
shells' less-than (<) operators are for. For the example above, the
canonical way to invoke it is this:

% my_script <the_file

(I cannot refrain from remarking that it's silly not to put the current
working directory in your PATH variable unless you don't trust the
other users of your system.)

Don't teach bad habits.
It's always bad to have . in path.
You are just begging to get raped.
It's not a matter of trusting other users on the system.

It's maybe possibly arguable for unpriviledged users but really even that is dumb.
*anything* might be written to your current dir any time by any process you run.
The extra time I spend typing "./" does not compare to even one time of spinning my wheels wondering why something is behaving so bizarre, having forgotten to check if maybe there is something in $PWD screwing up basic assumptions that should be safe. That are _supposed_ to be safe.
The alternative is having to specify the full explicit path to every binary, and shell built-in, you ever run, not just by hand but in every script and even compiled into many binaries.

It's one of those things that you as the owner of your box may do, but it's really irresponsible to ever even suggest to anyone else they do so.
Anyone working with computers should have habits based on being explicit and unambiguous anyways.
You should _want_ to be typing "./myscript" instead of "myscript" when you explicitly want to run some transient local temp file. If it's not a transient temp file and will be used more than once, then you can move it into ~/bin which can be in PATH and have your convenience just fine. There is absolutely no excuse for . in PATH.

--
Brian K. White brian@xxxxxxxxx http://profile.to/KEYofR
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: Can com+ Hotfix Rollup Package 27 fix my memory problem with WSH. CreateObject/CreateScript?
    ... Heh, improve your aim, then... ... Of course in script, the object will be ... > ignore best practice at your own risk. ...
    (microsoft.public.scripting.wsh)
  • Re: [PHP] Re: Hack question
    ... I assume using a php script because the owner is ... It would be nice to know if there is a CMS involved. ... That uploaded file is a temp file and gets deleted at the end of the script execution. ... "Some men are born to greatness, some achieve greatness, ...
    (php.general)
  • Re: TIP #210: Add tempname Subcommand to file
    ... > get an open temp file would be... ... > load $fname myPkg ... while we still write to it and before we get to [load] ... nothing we could possibly defend the script from, ...
    (comp.lang.tcl)
  • Scripting Help
    ... some of you more experienced script writers ... # WRITING COMMAND PARAMETERS TO TEMP FILE WHILE READING THE ... I have used the temp file as a means to expand the variables as the ... My problem is that when I try to cat utemp5 and pipe it to ksh that I ...
    (comp.unix.aix)
  • Re: Scripting Help
    ... some of you more experienced script writers ... > # WRITING COMMAND PARAMETERS TO TEMP FILE WHILE READING THE ... > I have used the temp file as a means to expand the variables as the ... > My problem is that when I try to cat utemp5 and pipe it to ksh that I ...
    (comp.unix.aix)