The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
why is it workin for 1 file , but not for multiple files? somanath Patrud Shell Programming and Scripting 1 01-23-2008 08:04 AM
recv() not workin fine..... mridula IP Networking 2 10-23-2005 03:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 10-05-2007
geeko geeko is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 15
rsh within awk is not workin

cat input.sh | awk '
{
cur1=tolower($1)

cur2=tolower($2)


rsh $cur1 report | grep $cur2

} '



hi,
Have a look at the above code, the input.txt file contains two words in each line with space as delimiter, the first word is computer name and the 2nd word is file name in that computer,

i tried to do rsh within awk command, i get error as

also this is a shell script and using awk command..

./madh1.sh: line 1: !#/bin/bash: No such file or directory
awk: cmd. line:13: rsh $cur1 report | grep tree | grep $cur2
awk: cmd. line:13: ^ syntax error
awk: cmd. line:13: rsh $cur1 report | grep tree | grep $cur2
awk: cmd. line:13: ^ syntax error

printing the string $cur1 and $cur2 works perfectly, but rsh is not working..

also if i do rsh outside of awk it works perfectly..

can you please help me..

thanks in advance,

regards,
geeko.

Last edited by geeko; 10-05-2007 at 02:04 AM..
  #2 (permalink)  
Old 10-05-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by geeko View Post
cat input.sh | awk '
{
cur1=tolower($1)

cur2=tolower($2)


rsh $cur1 report | grep $cur2

In an awk script, you must use awk commands; awk is not a shell.

To call a shell command from within an awk script, use the system() function.

(And you don't need to use cat; use the filename as an argument to awk.)
Quote:
} '



hi,
Have a look at the above code, the input.txt file contains two words in each line with space as delimiter, the first word is computer name and the 2nd word is file name in that computer,

i tried to do rsh within awk command, i get error as

./madh1.sh: line 1: !#/bin/bash: No such file or directory
awk: cmd. line:13: rsh $cur1 quota report | grep tree | grep $cur2
awk: cmd. line:13: ^ syntax error
awk: cmd. line:13: rsh $cur1 quota report | grep tree | grep $cur2
awk: cmd. line:13: ^ syntax error

printing the string $cur1 and $cur2 works perfectly, but rsh is not working..

also if i do rsh outside of awk it works perfectly..
  #3 (permalink)  
Old 10-05-2007
achneaz1 achneaz1 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 4
you have to send the shell variables into the awk script..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0