Operating System - HP-UX
1752272 Members
5646 Online
108786 Solutions
New Discussion юеВ

Connecting telnet users from shell script

 
SOLVED
Go to solution
Shailesh Joshi
Occasional Advisor

Connecting telnet users from shell script

Hello,

I want to write a shell script, which will test some unix user-ids. The user-ids could be either ftp ids or telnet ids. Testing for FTP-ids is easy. But for telnet ids, how should I connect to those users through script so that it will not prompt for passwords. I have user-id/pwds for all the users. All the users are present on the same machine and the script will also run from the same machine.

Does anybody know how to achieve this?

Thanks,
Shailesh
10 REPLIES 10

Re: Connecting telnet users from shell script

Looks like a job for expect:

http://hpux.connect.org.uk/hppd/hpux/Tcl/expect-5.41/

This will let you talk to the tty in script fashion...

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Naveej.K.A
Honored Contributor

Re: Connecting telnet users from shell script

hi shailesh

expect will do the job for you, as duncan has mentioned

with best wishes
Naveej
practice makes a man perfect!!!
Gabriele FACCHINI
Frequent Advisor

Re: Connecting telnet users from shell script

Hi Shailesh, I have make this script for you.
Try & say me.
By
Gabriele
Gabriele Facchini
Gabriele FACCHINI
Frequent Advisor
Solution

Re: Connecting telnet users from shell script

Excuse I have make an error, this is the correct version.
By
Gabriele
Gabriele Facchini
Shailesh Joshi
Occasional Advisor

Re: Connecting telnet users from shell script

Hi Gabriele,

The solution worked perfectly. In the script you have given different sleep times. Is that time fixed? And if yes, how did you arrive to those timings?

Thanks a lot for the help.

Thanks,
Shailesh
Shailesh Joshi
Occasional Advisor

Re: Connecting telnet users from shell script

Hi Duncan and Navjeet,

I tried the binary given by Duncan, but it didn't work. Actually I am working on a Solaris machine. Will that binary run on Solaris also? Being a new member I was not sure, whether I could post questions about Solaris on this list? So didn't mention about it.

Anyway, Thanks for ur help.

Thanks,
Shailesh
Gabriele FACCHINI
Frequent Advisor

Re: Connecting telnet users from shell script

Hi Shailesh the sleep time depend of the duration of the command. If you want to excute a command in a telnet script, you must launch it before in a shell, es:
# time
at the end of the output you read:
real 0.0
user 0.0
sys 0.0
You add the 3 times and you have the time for the sleep. You can add some seconds to the results.

By Gabriele
Gabriele Facchini

Re: Connecting telnet users from shell script

Shailesh,

Sorry, absolutely no way that a HP-UX binary is going to run on Solaris, or vice-versa - never have, never will!

Of course you can get expect binaries for Solaris. The equivalent site for Solaris users is:

http://www.sunfreeware.com/

You'll find expect here somewhere - make sure you download the correct version for your release of Solaris.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Nick D'Angelo
Super Advisor

Re: Connecting telnet users from shell script

Hello/Ciao Gabrielle,

I need to capture the system time in the log file before the ftp and after the ftp.

Also, the time before and after the remote telnet.

How can I do this?

Per Piacere/please.

Always learning