![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Shell script to manipulate a message count for the same IP @ diff session | gobinath | Shell Programming and Scripting | 1 | 05-28-2008 04:13 PM |
| running script after closing telnet | shinjeck | SUN Solaris | 2 | 10-29-2007 07:52 AM |
| Telnet Session to AIX | bluebee | UNIX for Dummies Questions & Answers | 1 | 08-07-2007 04:19 PM |
| Error closing read file | ALTRUNVRSOFLN | High Level Programming | 1 | 09-18-2006 12:29 PM |
| Telnet Session | pathanjalireddy | Shell Programming and Scripting | 6 | 04-06-2005 11:41 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
closing a telnet session on error, in a shell script
I am using a shell script to telnet into a remote unix server and execute certain commands. But if any command being executed remotely, throws an error, the script just hangs. And the telnet session does not get closed.
I want to be able to close the session and complete the script execution in case of an error or otherwise. Below is the script. Any help will be appreciated. #!/bin/sh ( echo open host sleep 1 echo user sleep 5 echo pswd sleep 4 sourceDir=$1 ; filename=$3 ; destDir=$2 echo "cd ${sourceDir}" sleep 1 echo "cp -rf ${filename} ${destDir} && \ cd ${destDir} && \ $cmd ; exit" ) | telnet I also want to be sure the previous command got executed before proceeding to execute the next command, which is why I'm using '&&'. This, not by using "sleep", but some other way of ensuring the earlier command did get executed successfully. The above script cribs at the echo of the last command. Snippet of the error is uctvd201:/opt/epds/EPDSDV01/epdata/SPONSOR/0000_071/test [EPDSDV01]# d && \ < sh: : Execute permission denied. uctvd201:/opt/epds/EPDSDV01/epdata/SPONSOR/0000_071/test [EPDSDV01]# ad && \ < sh: : not found. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|