[colug-432] Bash fun
meinwald.1 at osu.edu
Sun Nov 1 11:34:26 EST 2009
Eval doesn't do what you described, but from what you are using it for, you
don't need it at all. If you just put the line in the script:
mysql -u user -ppass -e "explain select this from that">>file.out
then it will run that line. Eval is effectively called on every line of your
script without you having to do anything.
The original behavior you described, of forking, would be accomplished with an
mysql -u user -ppass -e "explain select this from that">>file.out &
This will continue running the script simultaneously with the command. I would
caution against using this, because if the commands take different amounts of
time to run, their outputs will likely be out of order in the output file.
On 11/01/09 11:10, Tom Hanlon wrote:
> too funny, every time I post a question I find the answer the moment I
> hit send.
> Looks like I want "eval"
> Anyhow... any general bash advice in regards to writing good scripts,
> good tutorials, etc.
> I was tempted to go with Python because I could use the python
> practice, but I could also use the bash practice.
> This will be run on linux, but also open solaris....
> Is open solaris fair game for discussion ? How about open solaris with
> bulged capacitors on Motherboard ;-)
> So bash open solaris, environment issues.. ?? Are there any I need to
> be aware of.
> On 1 Nov 2009, at 11:02, Tom Hanlon wrote:
>> I am writing a script that takes a file of MySQL queries. I want to
>> read that file and then run explain for each query in the file and
>> gather a subset of the output generated.
>> So basic process is.
>> given file
>> select this from that;
>> select that from this;
>> I want to run
>> mysql -u user -ppass -e "explain select this from that">>file.out.
>> mysql -u user -ppass -e "explain select that from this">>file.out.
>> I am reading the lines from the file.. no problem, I am assigning them
>> to variables.
>> The exec, or eval or whatever it takes to fork a process and keep on
>> going is holding me up a little bit.
>> while read line
>> echo $line;
>> # exec seems to exit
>> ## exec who;
>> colug-432 mailing list
>> colug-432 at colug.net
> colug-432 mailing list
> colug-432 at colug.net
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5312 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.colug.net/pipermail/colug-432/attachments/20091101/090819b1/attachment.bin
More information about the colug-432