rsh within awk is not workin


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rsh within awk is not workin
# 1  
Old 10-05-2007
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  
Old 10-05-2007
Quote:
Originally Posted by geeko
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  
Old 10-05-2007
you have to send the shell variables into the awk script..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash regex evaluation not workin

I'm building a script that may received start and end date as parameters. I whant to make it as flexible as possible so I'm accepting epoch and date in a way that "date --date=" command may accept. In order to know if parameter provided is an epoc or a "date --date=" string I evaluate if the value... (2 Replies)
Discussion started by: lramirev
2 Replies

2. Shell Programming and Scripting

Cannot pass rsh and awk command into a variable

Hello, I'm having some issues getting a home dir from a remote server passed to a variable. Here is what I have so far: rsh server "(ls -ld /home*/user | awk '{print \$9}')" /home3/userThat works fine and brings back what I need. But when I try to add it to a variable it goes all... (3 Replies)
Discussion started by: elcounto
3 Replies

3. Shell Programming and Scripting

awk, double variable, for loop and rsh

Hello folks, I've a (perhaps) simple question. In a text file I've : server_name1: directory1 server_name2: directory2 server_name3: directory3 I want to make a loop that lets me connect and operate on every server: rsh server_name1 "ls -l directory1" I've tried with awk,... (6 Replies)
Discussion started by: gogol_bordello
6 Replies

4. Shell Programming and Scripting

determine the periodfor which user is workin

write a shell script that determines the period for which a specified user is workin on the system. (3 Replies)
Discussion started by: shawz
3 Replies

5. Shell Programming and Scripting

awk on a remote machine using 'rsh'

Hi, I want to do a awk operation on a file on a remote machine. I am using rsh for this. rsh <remote> awk '{print $2}' process.txt output: awk: syntax error near line 1 awk:illegal statement near line 1 I can do the awk operation by logging into the remote machine. Can... (1 Reply)
Discussion started by: eamani_sun
1 Replies

6. Shell Programming and Scripting

why is it workin for 1 file , but not for multiple files?

Hi , this peice of code is working for one file but not for multiple files. Can some one please tell me the reason??? for i in `ls -1 | egrep ''SOM.*` ; do filename=$(ls -1 $i) filename=$(print $filename) if ] then print "Skipping file $i since it already has... (1 Reply)
Discussion started by: somanath Patrud
1 Replies

7. Linux

Help in RSH

Hi All, I want to execute a command from my Windows machine to Linux machine. d:> rsh <Linux machine add> -l <user_name> pwd>dir in linux machine users home directory in .rhosts file I entered the windows machine IP address and user name. In linux etc/hosts.equiv file I entered the... (1 Reply)
Discussion started by: sarwan
1 Replies

8. IP Networking

recv() not workin fine.....

hi ! In my program I have a structure as shown below: struct data { int a; char *b; long c; }str; i have assigned the following values to it: strcpy(str.b,"John"); str.a=10; str.c=123435; The client is tryin to send struct data to the server using send(sock,(char *... (2 Replies)
Discussion started by: mridula
2 Replies

9. UNIX for Advanced & Expert Users

where is rsh

Hi, when a user use rsh command (or any other) , where is the executable used by him ? Many thanks in advance. (1 Reply)
Discussion started by: big123456
1 Replies

10. Shell Programming and Scripting

help with rsh

I am trying to run a Perl script using rsh. I need to be able to capture the return code value, so the calling script can handle failures properly. I cannot modify the Perl script I need to run because we use it for all of our servers. Does anyone have a suggestion? (1 Reply)
Discussion started by: kscase
1 Replies
Login or Register to Ask a Question