Rsh: test $? on remote system.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rsh: test $? on remote system.
# 1  
Old 12-10-2003
Rsh: test $? on remote system.

Hi,
a little help.

I need to test the return code of a list file command on a remote system (Unix) using the rsh command. More exactly, to test is a directory exists, I try the following command:

rsh $remoteHost "ls -la " $DirRemote

Now, if the $DirRemote is not correct and I test the $? I found 0.

If I try to check the $? on remote system for this remote command, in this way

rsh $remoteHost "ls -la " $DirRemote " ; echo $?"

to capture a value different, the value is always 0, preceded by an error message.

Any idea?
Thanks in advance.

Giovanni
# 2  
Old 12-10-2003
I really don't know anything about the rsh command, but you could try PxT's idea.. no idea if it works or not since the OP never responded.

Here's another post, but I'm not sure how much help it'll be either.
# 3  
Old 12-10-2003
Thanks a lot oombera!
My problem was the single quotes not used in my code!

Now I solved the problem in this way:

rsh $remoteHost 'ls -la $DirRemote >/dev/null 2>$1 ; echo $?'

and the return code is correctly set to 2.
# 4  
Old 12-11-2003
Originally posted by gio123bg

rsh $remoteHost 'ls -la $DirRemote >/dev/null 2>$1 ; echo $?'

----------------------------------------------------------------------------------

Won' t you think using single quotes for the whole thing will be good

like

'rsh $remoteHost 'ls -la $DirRemote >/dev/null 2>$1 ; echo $?'

I think this will tell you if the rsh fails and your ls passes.

Cheers
JK
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

execute remote commands with rsh

Hi, I earlier determined I cannot use FTP to execute remote commands on a server. My problem, I need to use a second server to get/put files via ftp onto my primary server and various tertiary servers. my server(A) ---> server (B) ----> server blah(c), server balh(C) I cannot directly... (1 Reply)
Discussion started by: mcclunyboy
1 Replies

2. Red Hat

How to enable and test the rsh and rcp in RHEL 5.3?

Hello, Can you help me on how to activate the rsh and rcp services. And also how do i test it after i have enable it Thanks. (7 Replies)
Discussion started by: shtobias
7 Replies

3. 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

4. Shell Programming and Scripting

command not working with rsh(remote shell)

Hi, root@air01a>SS7Manager -status This command gives correct output. But when I write this in script and run it on SUNMC (which can connect to air01 and by default login as root). It gives the error "SS7manager not found" or "can not open". Here is the scripts. #!/bin/sh rsh air01a... (4 Replies)
Discussion started by: lastkey
4 Replies

5. Solaris

rsh commands not getting executed from Solaris 10 System to AIX System

Hi Friends, I am trying to execute rsh commands from Solaris 10 system to AIX system. When I give; Solaris10# rsh <hostname> ls -l , it gives me an error rshd : 0826-826 The host name for your address is not known At the same time, Solaris10# rsh <hostname> ---- gives me remote shell of... (25 Replies)
Discussion started by: jumadhiya
25 Replies

6. Shell Programming and Scripting

Script using rsh(remote shell)

Hi, I am writing a script that will require me to perform tasks across servers. I tried to use rsh <host> "Commands..." > /dev/null 2>&1. However, I am required to execute a long series of commands after that and rsh does not seem to support this and its also insecure. I tried to use rsh to... (5 Replies)
Discussion started by: joseph_ng
5 Replies

7. UNIX for Advanced & Expert Users

rsh: remote tape backup

I am trying to perform a remote tape backup from one SCO openserver to another remote SCO Openserver which happens to have a tape drive configured. I have added entries into host.equiv and .rhosts on the tape drive server: prodution_server root # This is equivalent to the hostname and... (1 Reply)
Discussion started by: cstovall
1 Replies

8. UNIX for Dummies Questions & Answers

RSH - Remote Shell

Dear All, I was wondering if there was any way that I could make RSH be non-blocking? i.e. make a remote connection to another machine and execute a function while being able to resume your program. T (4 Replies)
Discussion started by: thoang
4 Replies

9. Shell Programming and Scripting

rsh help with remote prompts

Hi, I'm writing a shell script that rsh's onto a remote machine and runs a perl script that requires values to be entered as the script executes. I also need to ba able to see the outputs from the perl script. When I try to run it I get an stty : Invalid argument and understand that this is... (4 Replies)
Discussion started by: ianf
4 Replies

10. UNIX for Dummies Questions & Answers

remote login through a script ( except rsh)

Hi Guys, I'm having a problem trying to change to a different user within a script . I want to change to a specific user and then run the subsequent commands using his previleges . I remember having used ' su ' some years back for this , can't figure it out now !! Help appreciated . (3 Replies)
Discussion started by: rahma
3 Replies
Login or Register to Ask a Question