![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| does any one know free web server to embed in my app | umen | High Level Programming | 4 | 03-18-2008 10:47 AM |
| Can anyone find a bug in this code?? shell script | amon | Shell Programming and Scripting | 1 | 09-19-2006 02:11 AM |
| Capture Oracle return code in shell script | Vikas Sood | Shell Programming and Scripting | 1 | 05-22-2006 05:32 PM |
| Store return code of shell script in oracle table | sveera | Shell Programming and Scripting | 3 | 05-04-2005 01:25 PM |
| Hide code in shell script??? | alan | Shell Programming and Scripting | 11 | 08-01-2003 11:33 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to embed shell script in a awk code
I have written a code to extract comma seperated values from a file and assign them to a variable inside awk code.i want to use one of these variable to be used in wget function i.e to pass the siteurl.How i can implement the shell command wget inside the awk for loop.code snippet is shown below.
Note:1.sitenames is a csv files name. awk -F, '{split($0,ar,","); for(i=0;i<1;i++) { siteurl=ar[1]; size=ar[2]; nkeys=ar[3]; print siteurl; print size; print nkeys; # wget www.real.com -o test.txt for(j=0;j<nkeys;j++) { k=4; keywords=ar[k+j]; print keywords; } } }' sitenames regards, Raj |
|
||||
|
Anbu,
The code which you sent is working but if i pass the siteurl as a variable it do not work.Any ideas how to make it read the value of the siteurl as variable. I tried this but not working. system ( "wget $siteurl -o test.txt" ) Regards, Raj |
|
||||
|
Hi Marikle,
First of all thank you for your prompt response. Its giving the following error: testawk.sh: line 19: syntax error near unexpected token `(' testawk.sh: line 19: ` nawk -v site_url=$siteurl '{system ("wget " site_url " -o test.txt)}'' I am attaching the full code : awk -F, '{split($0,ar,","); for(i=0;i<1;i++) { siteurl=ar[1]; size=ar[2]; nkeys=ar[3]; print siteurl; print size; print nkeys; # echo $nkeys; nawk -v site_url=$siteurl '{system ("wget " site_url " -o test.txt)}' # system ( "wget ${siteurl} -o test.txt" ) # wget www.rhapsody.com -o test.txt for(j=0;j<nkeys;j++) { k=4; keywords=ar[k+j]; print keywords; } } }' sitenames Let me know where i am doing wrong?/ Regards, Rajesh |
|
||||
|
still it shows the same error.I am not able to figure out why?/
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|