Failed to check status code in "rsh" command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Failed to check status code in "rsh" command
# 8  
Old 07-03-2006
Hey vino my freiend!

Thanks!
You solved my syntax problem,but I still have a funcionality problem with the condition.

Following nir.ksh content:
Code:
#! /bin/ksh

CONF_FILE=nir.conf
export $(< $CONF_FILE)
run_install_sr()
{
nawk -F'[=:]' '$1 ~ "^INSTALL_SR_" && $NF = "Y" {print $2}' "${CONF_FILE}" | whi
le read INSTALL_SR_DIR
do
  rc=$(rsh ${DB_HOST_NAME} hostname && echo OKAY)
status=$?
if [[ $status -eq 0 ]]    # remsh command successful, now get remsh rc...
        then
            if [[ "$rc" = 'OKAY' ]]
            then
                echo " all is well"
            else
                echo "remote failure"
            fi
else
     echo "local failure: remsh"
fi

done
}
run_install_sr

The problem is with the condition:
if [[ "$rc" = 'OKAY' ]]
then
echo " all is well"
else
echo "remote failure"
fi

When I run the script I get the output : "remote failure",despite of the fact that there is no problem to get to the remote server.

I want to check the status which returned back from a remote server.
How to do it right?

Thanks in advance,
Nir
# 9  
Old 07-03-2006
Code:
  rc=$(rsh ${DB_HOST_NAME} hostname && echo OKAY)
status=$?

I think it must have something to do with the above code.

Try something like

Code:
rsh ${DB_HOST_NAME} hostname
status=$?
if [[ $status -eq 0 ]] ; then
  rc=OKAY
fi ;

# 10  
Old 07-03-2006
Thanks pal but I'm still does not catch the correct status from the command I run on the remote server.

My code is now as the following:
Code:
CONF_FILE=nir.conf
export $(< $CONF_FILE)
run_install_sr()
{
nawk -F'[=:]' '$1 ~ "^INSTALL_SR_" && $NF = "Y" {print $2}' "${CONF_FILE}" | whi
le read INSTALL_SR_DIR
do
  rsh ${DB_HOST_NAME} hostnam
  status=$?
  if [[ $status -eq 0 ]] ; then
    rc=OKAY
  fi
            if [[ "$rc" = 'OKAY' ]]
            then
                echo " all is well"
            else
                echo "remote failure"
            fi
done
}
run_install_sr

I changed the command "hostname" to "hostnam"
I ran the script:
Code:
bounty:# ./nir.ksh 
ksh: hostnam: not found
 all is well

I expected to get "remote failure" and not "all is well".

Any more ideas?

Thanks in advance,
Nir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

2. Solaris

svc:/network/physical:default: Method "/lib/svc/method/net-physical" failed with exit status 96. [ n

After a memory upgrade all network interfaces are misconfigued. How do i resolve this issue. Below are some out puts.thanks. ifconfig: plumb: SIOCLIFADDIF: eg000g0:2: no such interface # ifconfig eg1000g0:2 plumb ifconfig: plumb: SIOCLIFADDIF: eg1000g0:2: no such interface # ifconfig... (2 Replies)
Discussion started by: andersonedouard
2 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Solaris

How to check "faulty" or "stalled" print queues - SAP systems?

Hi all, First off, sorry for a long post but I think I have no other option if I need to explain properly what I need help for. I need some advise on how best to check for "faulty" or "stalled/jammed' print queues. At the moment, I have three (3) application servers which also acts as print... (0 Replies)
Discussion started by: newbie_01
0 Replies

5. UNIX for Dummies Questions & Answers

Unable to use the Sudo command. "0509-130 Symbol resolution failed for sudo because:"

Hi! I'm very new to unix, so please keep that in mind with the level of language used if you choose to help :D Thanks! When attempting to use sudo on and AIX machine with oslevel 5.1.0.0, I get the following error: exec(): 0509-036 Cannot load program sudo because of the following errors:... (1 Reply)
Discussion started by: Chloe123
1 Replies

6. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. AIX

xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?

AIX 4.2 I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works... (2 Replies)
Discussion started by: Browser_ice
2 Replies

9. UNIX for Dummies Questions & Answers

Command 'rm -f -r "0yfOYy-0008Nq-2j-32233-K"' failed with return code 1 and error mes

I would like to know what means this error and how to fix it Command 'rm -f -r "0yfOYy-0008Nq-2j-32233-K"' failed with return code 1 and error message Thank you (3 Replies)
Discussion started by: linuxbee
3 Replies

10. Shell Programming and Scripting

check input = "empty" and "numeric"

Hi how to check input is "empty" and "numeric" in ksh? e.g: ./myscript.ksh k output show: invalid number input ./myscript.ksh output show: no input ./myscript.ksh 10 output show: input is numeric (6 Replies)
Discussion started by: geoffry
6 Replies
Login or Register to Ask a Question