1821060 Members
2574 Online
109631 Solutions
New Discussion юеВ

Auto Login via Script

 
John Porter_5
New Member

Auto Login via Script

Hello all,

I am new to the forum and to scripting so please forgive my ignorance.

I need to create a simple script that will execute the login command to log in a phantom user. So far I have 'exec login "username"', which works just fine, but nothing else I try will pass the password to the password prompt.

What command can I use from withing the script to pass the password to the password prompt?

Thanks ahead of time,

John
3 REPLIES 3
Bill Hassell
Honored Contributor

Re: Auto Login via Script

You didn't mention whether this login was using telnet, rlogin or ssh. For telnet and rlogin, the usual answer is to use Expect, a language that can automate interactive tasks such as login. However, Expect needs to be downloaded along with dependencies and installed. Then there's the 600 page manual...

The best choice is to use ssh and public keys. The scripting is quite simple with ssh.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Auto Login via Script

Once you execute exec login "username" you are gone from your script and can only be interactive with the process.

As Bill mentioned, if you use expect, you must create another process so both can exist.
OldSchool
Honored Contributor

Re: Auto Login via Script

you may also need to determine, from the person giving you this request, what they hope to attain by having this automated login.

It could very well be that just having the login won't solve what what they want to fix. I don't believe that the requestor gave you sufficient information, as in "what's supposed to happen once is logged in".