Sponsored Content
Top Forums Shell Programming and Scripting Unable to close telnet session from script Post 302500268 by drbiloukos on Monday 28th of February 2011 09:57:57 AM
Old 02-28-2011
Unable to close telnet session from script

Hello people, I am creating a script that will alert me in an ftp or telnet account on my system expires. FTP part is ok, but when I am entering the 3 script, it stucks. I can see that the script will not close the telnet seession. Can you please check and let me know what I am doing wrong? What if I send a CTRL-C in the script, will it work for the telnet sessin?

Code:
!/bin/sh
bill=bill@gmail.com
LOGS=/home/bill/scripts_logs
SCRIPTS=/home/bill/scripts

${SCRIPTS}/bill_ftp_check.sh > ${LOGS}/bill_ftp_check.log 2>&1
${SCRIPTS}/bill2_ftp_check.sh > ${LOGS}/bill2_ftp_check.log 2>&1
${SCRIPTS}/bill3_check.sh > ${LOGS}/bill3_check.log 2>&1
${SCRIPTS}/bill_check.sh > ${LOGS}/bill4.log 2>&1

grep failed ${LOGS}/bill_ftp_check.log
if [ $? -eq 0 ]
   then
   mailx -s "bill_ftp account expired" $bill < ${LOGS}/bill_ftp_check.log
fi

grep failed ${LOGS}/bill2_ftp_check.log
if [ $? -eq 0 ]
   then
   mailx -s "bill2_ftp account expired" $bill < ${LOGS}/bill2_ftp_check.log
fi

grep "Your password will expire" ${LOGS}/bill3_check.log
if [ $? -eq 0 ]
   then
   mailx -s "bill3 account is about to expire" $bill < ${LOGS}/bill3_check.log
fi

grep "Your password will expire" ${LOGS}/bill4_check.log
if [ $? -eq 0 ]
   then
   mailx -s "bill4 account is about to expire" $bill < ${LOGS}/bill4_check.log
fi

sleep 5

rm ${LOGS}/bill_ftp_check.log
rm ${LOGS}/bill2_ftp_check.log
rm ${LOGS}/bill2_check.log
rm ${LOGS}/bill4_check.log

exit

WHERE bill3_check.sh

Code:
#!/bin/sh

(echo open 10.0.0.10
sleep 2
echo bill3
sleep 2
echo billpass
sleep 2
echo close) | telnet

exit

Thank you in advance !

---------- Post updated at 04:57 PM ---------- Previous update was at 12:08 PM ----------

Anyone ?

Smilie
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

telnet session timeout

hi, we can set something such that if the user has been idle for a while, it will auto disconnect. where to do so? thanks (6 Replies)
Discussion started by: yls177
6 Replies

2. Shell Programming and Scripting

Telnet Session

{ sleep 2 echo "$user" sleep 2 echo "$password" sleep 2 echo " ls" sleep 10 echo "exit" }| telnet $server I have a machine x and i have executed the above script on machine 'x'. i entered the... (6 Replies)
Discussion started by: pathanjalireddy
6 Replies

3. Shell Programming and Scripting

How to close TELNET Connection

Hi, I have logged into a system using Telnet and iam unable to close the connection to connect to the next system using arrays. Iam getting error "Connection Timed Out" Iam using net::Telnet module. Please suggest.. (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

4. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: farahzaiba
1 Replies

5. UNIX for Dummies Questions & Answers

command to close telent session when login incorrect

i need a command to close telnet session wen login incorrect..i want to embed it into my perl script for telnet to check for login incorrect error. (2 Replies)
Discussion started by: raksha.s
2 Replies

6. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

7. Shell Programming and Scripting

Expect script to automate telnet session

Hi all, I am currently running a daemon which creates a virtual terminal for testing purposes. Essentially, if I were to interact with it manually, this is what I get. john@test1:~$telnet localhost 7777 Trying ::1... Connected to localhost. Escape character is '^]' mip6d> pl eth2... (6 Replies)
Discussion started by: abxccd
6 Replies

8. Shell Programming and Scripting

Work with setsid to open a session and close it correctly

I would like to create the following script: run a python script with setsid python may or may not fail with exception check if all of the group processes were terminated correctly if not, kill the remaining processes How can I do that? Thanks a lot (3 Replies)
Discussion started by: ASF Studio
3 Replies

9. Shell Programming and Scripting

How to break out of hung or waiting telnet session in shell script?

I have to put together telnet instructions for 100s of hosts for verifying basic connectivity and get output in a neat format. Problem- If a telnet is hung with message "Trying .... <hostname" due to firewall or routing issue the commands waits for a very long time before it times out and my... (2 Replies)
Discussion started by: desiphantom
2 Replies
XSLT_SET_LOG(3) 							 1							   XSLT_SET_LOG(3)

xslt_set_log - Set the log file to write log messages to

SYNOPSIS
void xslt_set_log (resource $xh, [mixed $log]) DESCRIPTION
This function allows you to set the file in which you want XSLT log messages to, XSLT log messages are different than error messages, in that log messages are not actually error messages but rather messages related to the state of the XSLT processor. They are useful for debugging XSLT, when something goes wrong. By default logging is disabled, in order to enable logging you must first call xslt_set_log(3) with a boolean parameter which enables log- ging, then if you want to set the log file to debug to, you must then pass it a string containing the filename. PARAMETERS
o $ xh -The XSLT processor link identifier, created with xslt_create(3). o $log - This parameter is either a boolean value which toggles logging on and off, or a string containing the logfile in which log errors too. RETURN VALUES
No value is returned. NOTES
Note Please note that file:// is needed in front of the path when using Windows. EXAMPLES
Example #1 Using the XSLT Logging features <?php $xh = xslt_create(); xslt_set_log($xh, true); xslt_set_log($xh, getcwd() . '/myfile.log'); $result = xslt_process($xh, 'dog.xml', 'pets.xsl'); echo $result; xslt_free($xh); ?> PHP Documentation Group XSLT_SET_LOG(3)
All times are GMT -4. The time now is 09:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy