Sponsored Content
Top Forums Shell Programming and Scripting Failed to check status code in "rsh" command Post 302078509 by nir_s on Saturday 1st of July 2006 08:28:25 AM
Old 07-01-2006
Failed to check status code in "rsh" command

Hi folks,

I wrote a ksh program which run scripts from remote server.
To check the status code I wrote the following function:


Code:
check_remote_status()
{
status_code=`tail -1 $installLog`
if [[ ${status_code} -ne 0 ]] ; then
  echo $errMsg | tee -a $installLog
  exit 1
else
  echo $validMsg >> $installLog
fi
}

The main function is:

Code:
run_install_sr()
{
cat ${CONF_FILE} | grep INSTALL_SR_ | grep :Y | while read line
do
  INSTALL_SR_DIR=`echo $line | cut -d= -f2 | cut -d: -f1`
  errMsg="ERROR: Failed to copy ${RESPONSE_FILE_SR} to ${DB_HOST_NAME}!"
  validMsg="-> VALID: ${RESPONSE_FILE_SR} was copied to ${DB_HOST_NAME}."
  rcp ${RESPONSE_FILE_SR} ${DB_HOST_NAME}:/tmp >> $installLog
  check_remote_status

  errMsg="ERROR: Failed to run SR database layer!"
  validMsg="-> VALID: SR Database layer completed successfully."
  rsh ${DB_HOST_NAME} "su - root -c \"cd ${INSTALL_SR_DIR} && ./Install_SR.ksh -f /tmp/${RESONSE_FILE_SR##*/} -l database"'; echo $?"' | tee -a $installLog
  check_remote_status

  errMsg="ERROR: Failed to copy ${RESPONSE_FILE_SR} to ${ADMIN_HOST_NAME}!"
  validMsg="-> VALID: ${RESPONSE_FILE_SR} was copied to ${ADMIN_HOST_NAME}."
  rcp ${RESPONSE_FILE_SR} ${ADMIN_HOST_NAME}:/tmp >> $installLog
  check_remote_status

  errMsg="ERROR: Failed to run SR RiGHTv administration layer!"
  validMsg="-> VALID: SR RiGHTv administration layer completed successfully."
  rsh ${ADMIN_HOST_NAME} "su - root -c \"cd ${INSTALL_SR_DIR} && ./Install_SR.ksh -f /tmp/${RESPONSE_FILE_SR##*/} -l administration"'; echo $?"' | tee -a $installLog
  check_remote_status

  if [[ ${RTESUB_LAYER} = 'YES' ]] && [[ ${ADMIN_LAYER} = 'YES' ]] ; then

     errMsg="ERROR: Failed to copy ${RESPONSE_FILE_SR} to ${RTESUB_HOST_NAME}!"
     validMsg="-> VALID: ${RESPONSE_FILE_SR} was copied to ${RTESUB_HOST_NAME}."
     rcp ${RESPONSE_FILE_SR} ${RTESUB_HOST_NAME}:/tmp >> $installLog
     check_remote_status

     errMsg="ERROR: Failed to run SR RTE subscriber layer!"
     validMsg="-> VALID: SR RTE subscriber layer completed successfully."
     rsh ${RTESUB_HOST_NAME} "su - root -c \"cd ${INSTALL_SR_DIR} && ./Install_SR.ksh -f /tmp/${RESPONSE_FILE_SR##*/} -l subscriber"'; echo $?"' | tee -a $installLog
     check_remote_status
  fi
done
}

When the program call to check_remote_status function ,I get the following error message to the screen:
E.g:
./RiGHTvInstaller.ksh[2]: -> VALID: SR RiGHTv administration layer completed successfully.: syntax error

Any ideas why?

Thanks in advance,
Nir
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
error(n)						       Tcl Built-In Commands							  error(n)

__________________________________________________________________________________________________________________________________________________

NAME
error - Generate an error SYNOPSIS
error message ?info? ?code? _________________________________________________________________ DESCRIPTION
Returns a TCL_ERROR code, which causes command interpretation to be unwound. Message is a string that is returned to the application to indicate what went wrong. The -errorinfo return option of an interpreter is used to accumulate a stack trace of what was in progress when an error occurred; as nested commands unwind, the Tcl interpreter adds information to the -errorinfo return option. If the info argument is present, it is used to initialize the -errorinfo return options and the first increment of unwind information will not be added by the Tcl interpreter. In other words, the command containing the error command will not appear in the stack trace; in its place will be info. Historically, this feature had been most useful in conjunction with the catch command: if a caught error cannot be handled successfully, info can be used to return a stack trace reflecting the original point of occurrence of the error: catch {...} errMsg set savedInfo $::errorInfo ... error $errMsg $savedInfo When working with Tcl 8.5 or later, the following code should be used instead: catch {...} errMsg options ... return -options $options $errMsg If the code argument is present, then its value is stored in the -errorcode return option. The -errorcode return option is intended to hold a machine-readable description of the error in cases where such information is available; see the return manual page for information on the proper format for this option's value. EXAMPLE
Generate an error if a basic mathematical operation fails: if {1+2 != 3} { error "something is very wrong with addition" } SEE ALSO
catch(n), return(n) KEYWORDS
error Tcl error(n)
All times are GMT -4. The time now is 06:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy