unix shell script question
Jul 19, 2006 at 1:30 PM Thread Starter Post #1 of 13

NotoriousBIG_PJ

Step 1: Plug power cable into wall. Step 2: Plug other end of power cable into....umm.... Step 0.5: Order something to power with power cable.
Joined
Mar 12, 2002
Posts
3,487
Likes
22
Hi,

I have a shell script that connects to another server. The server then prompts for a pw. How would I go about making my script fill in this pw?

Thanks,

Biggie.
 
Jul 19, 2006 at 2:17 PM Post #2 of 13
Quote:

Originally Posted by NotoriousBIG_PJ
Hi,

I have a shell script that connects to another server. The server then prompts for a pw. How would I go about making my script fill in this pw?

Thanks,

Biggie.



What command are you using to connect to the server?
 
Jul 19, 2006 at 3:42 PM Post #3 of 13
Quote:

Originally Posted by rsabo
What command are you using to connect to the server?


rlogin or telnet

Biggie.
 
Jul 19, 2006 at 7:11 PM Post #5 of 13
Quote:

Originally Posted by mjg
biggie,

can you use SSH? It might make things easier.



Only in certain instances.

Biggie.
 
Jul 19, 2006 at 8:19 PM Post #7 of 13
Is there any way in unix to auto answer prompts?

Biggie.
 
Jul 19, 2006 at 9:48 PM Post #8 of 13
Just pipe (or redirect) the password to Telnet in the same way that you're sending all the other commands to Telnet. There's nothing special or different about how you handle passwords.

As usual, the standard warnings about using Telnet apply. If there's any possibility at all of the communication leaving your firewalled local network on its way to the server, Telnet should not be used because the password travels as cleartext. Even then, sysadmins at most places ban Telnet because of the risk of a rogue employee or intruder sniffing packets on the local network.
 
Jul 19, 2006 at 10:02 PM Post #9 of 13
Have you looked into Expect?

I think this is what you're looking for <waves hand>
 
Jul 19, 2006 at 10:19 PM Post #10 of 13
As psychogentoo said, 'expect' will allow you to have a script send responses based on information received (such as a request for a password). You really should attempt to use SSH over telnet though for security reasons (telnet transmits your passwords and any other sensitive data in plain readable text which can easily be picked up by anyone along the network without much difficulty at all). Furthermore, if you're going to put a password into a shell/expect script, you should make sure that the permissions are such that they're not easily readable by others.

Using SSH with authorized_keys files setup really would be the best option if you can convince the remote side to use an sshd. See http://www.arches.uga.edu/~pkeck/ssh/ for instructions on how it can be done.
 
Jul 20, 2006 at 3:51 AM Post #11 of 13
Quote:

Originally Posted by NotoriousBIG_PJ
Is there any way in unix to auto answer prompts?

Biggie.



"here documents" might do it.
http://www.faqs.org/docs/abs/HTML/here-docs.html

Usernames, passwords, or anything else can be entered on the command line when you invoke the script. Although I agree that for anything with passwords you should run over ssh or another secure/encrypted mechanism.

Although... Didn't know about expect. That looks better.
 
Jul 20, 2006 at 2:30 PM Post #13 of 13
Thanks for the replys.

I have another question, is there a windows program I can install that will allow me to remap keys (ie. I press F1 key and 'telnet aaaab' is typed on the screen. I haven't been able to find something like this using google yet.

edit: Ah I figured it out, keystroke/keyboard macros is what I was looking for

Biggie.
 

Users who are viewing this thread

Back
Top