[ale] scripts, file I/O, and loss of hair

Jim Kinney jim.kinney at gmail.com
Thu May 12 17:57:42 EDT 2011


On Thu, May 12, 2011 at 5:14 PM, The Don Lachlan <ale-at-ale.org@
unpopularminds.org> wrote:

> On Thu, May 12, 2011 at 02:10:25PM -0400, Jim Kinney wrote:
> > I have a simple test script my_script
> >
> > #!/bin/bash
> > # this is a crap script
> > myout="$2"'.crap'
> > directions=$(cat $2)
> > echo "$myout"
> > echo "$directions"
> > exit
> >
> > It is launched by:
> > ./my_script < test1.dat
> >
> > which is a file containing one line
> > /tmp/
> >
> > which will be used later once the I/O issue is corrected.
> > This is being done to replicate a much larger scenario
> >
> > When it is run, the output is:
> > .crap
> > /tmp/
> >
> > Notice that the file I want to be named test1.dat.carp is only named
> .crap
> > I need to get the name of the input file into the script itself somehow.
> > Positional parameters as not doing it.
>
> Dude,
>
> The redirect < terminates the arguments to your script; everything from the
> redirect on is completely separate.
>
> $ ./myscript test1.dat
>
> Then open the file inside your script. Yes, I'm speaking truth.
>

yeah, but...

myscript is a temp hack for testing. The real code is a honking huge binary
that expects a {binary name} < {input data file}. {input data file} is
variably named and often 20+MB. Changing {binary name} to work better is
political (think Fortran 77 base code - someone in charge got their PhD with
that program).

so things must work as they are with my little tweaks around the edges.
until I blow away the decades old mess and start over in C.


> Also,
>
>  directions=$(cat $2)
>
> should be replaced by
>
>  directions=`<${1}`
>
> See Useless Use of Cat - http://partmaps.org/era/unix/award.html#cat
>

meh. Having enough I/O redirect issues already that making Schwartz happy
was just not gonna happen today.

besides, having a file named crap to be read with cat is, well, funny. :-)


> -L
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
-- 
James P. Kinney III

As long as the general population is passive, apathetic, diverted to
consumerism or hatred of the vulnerable, then the powerful can do as they
please, and those who survive will be left to contemplate the outcome.
- *2011 Noam Chomsky*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20110512/56a9ab77/attachment-0001.html 


More information about the Ale mailing list