Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie to KSH Please help

Status
Not open for further replies.

hg4372

Technical User
Feb 9, 2009
43
0
0
US
#!/usr/bin/ksh
# echo "Enter market: \c"
# read market
# echo "Enter username: \c"
# read username
# echo "Enter password: \c"
# read password
market=$1
dt=$(date +%m%d%y)
username=test
password=test

for x in 1
do
{
echo $username
sleep 5
echo $password
sleep 10
echo "print tester.log"
sleep 60
echo "exit;"
}|telnet $market>>/export/home/tester/log/$market.DAILY_$dt

done

Bare with me, I will try to explain what I'm trying to accomplish.

My cron launches a get_tester file that runs this script against 8 different markets. I only want to telnet into each market one time, however I want to print the tester.log file to to the /export/home/tester/log directory then have another do statement to allow me to stay telneted in but print a different file directed to a different file.

Something like this ?

do
{
echo $username
sleep 5
echo $password
sleep 10
echo "print tester.log"
sleep 60
echo "exit;"
}|telnet $market>>/export/home/tester/log/$market.DAILY_$dt

do
{
echo "print helpme.log"
sleep 10
| $market>>/export/home/helpme/log/$market.DAILY_$dt

)
done
done

Please help
 
Would you be able to provide an example of this using expect? I've never messed with that at all.
 
There is a utility called autoexpect which will generate an expect script for you. Try that and see how you go... the script will need editing to remove a lot of the recorded text which may differ for each telnet target.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top