shell script with awk line that doesnt execute a further shell command

shell script with awk line that doesnt execute a further shell command

Post by Peter Guya » Fri, 11 Aug 2006 20:31:44


Hi

Newbie-question.


These lines work if executed from shell.

wget -O "16" http://www.yqcomputer.com/ | sh

wget -O "1" " http://www.yqcomputer.com/ " | sh

But within my bash-script it doesnt work. So there might be some escape sequence
problems.

The line is "produced" from a awk line in a bash script:

awk -F[=\"\<\>] ' BEGIN { zaehler=0; } /HREF/ && /bger/ && /jump/ { link=$5 "="
$6; dnr=$6; zaehler++; print "wget -O " "\"" zaehler "\"" " " "\""link"\"" " \|
sh " }' $pfad$zieldatei

Any helpfull hint is appreciated. tnx.

Peter Guyan
 
 
 

shell script with awk line that doesnt execute a further shell command

Post by Juergen Ka » Fri, 11 Aug 2006 20:43:17


There is a question mark around herr ^^^^.
Does this really work.


I think you must surround the URL with quotes (').

 
 
 

shell script with awk line that doesnt execute a further shell command

Post by Peter Guya » Fri, 11 Aug 2006 21:20:31

Juergen Kahrs schrieb:
I dont get the point. what is the herr ^^^^ thing.

I tried with single quotes and double quotes without success.
 
 
 

shell script with awk line that doesnt execute a further shell command

Post by Bob Harri » Fri, 11 Aug 2006 21:46:20

In article <cOECg.65$ XXXX@XXXXX.COM >,



If I understand correctly you have created a command that looks
kind of like this:

wget ... | sh

Which is going to fetch a document from the web an pass that
document to the shell to be processed as shell commands.

I've looked at the documents. It is _NOT_ a shell script. It is
just text. It actually looks like a form to be filled out.

Are you sure this is what you intend?

I was wondering if maybe you wanted to do something like the
following:

awk -F[=\"\<\>] ' BEGIN { zaehler=0; } /HREF/ && /bger/ && /jump/
{ link=$5 "="
$6; dnr=$6; zaehler++; print "wget -O " "\"" zaehler "\"" " "
"\""link"\"" }' $pfad$zieldatei | sh

Notice I moved the 'sh' from the print statement to be something
awk pipes it output into.

That is to say awk generates a bunch of wget commands and these
commands are passed from awk to sh where they are executed.

Bob Harris
 
 
 

shell script with awk line that doesnt execute a further shell command

Post by Peter Guya » Sat, 12 Aug 2006 01:59:36

Bob Harris schrieb:

Yes.


No, no any more.

This is exactely what i wanted.

Perfekt.
Thank you.
 
 
 

shell script with awk line that doesnt execute a further shell command

Post by Ed Morto » Sun, 13 Aug 2006 12:42:58


I think your life would be easier (and your script clearer) if you let
awk do what it does welll (i.e. the record selection and field printing)
but then let shell do the shell scripting, so instead of munging it all
into this:

awk -F[=\"\<\>] ' BEGIN { zaehler=0; } /HREF/ && /bger/ && /jump/
{ link=$5 "=" $6; dnr=$6; zaehler++; print "wget -O " "\"" zaehler "\""
" " "\""link"\"" }' $pfad$zieldatei | sh

you do this:

awk -F[=\"\<\>] '/HREF/ && /bger/ && /jump/ {print ++nr,$5,$6}'
"$pfad$zieldatei" |
while read zaehler fld dnr
do
wget -O "$zaehler" "${fld}=${dnr}"
done

Regards,

Ed.