Using Telnet in a script

Hi All,

I was trying to use telnet in a script to access a certain processor on a certain port to view some processes. The problem is that when I use telnet the output is displayed for me.

The script is:
#!/bin/sh
cd /ahmed/ezzat/
rm ss7trace.log
touch ss7trace.log
chmod 755 ss7trace.log
telnet 172.16.0.9 8100
ps > result
quit

At the line of telnet I get an output:
Trying 172.16.0.9...
Connected to 172.16.0.9.
Escape character is '^]'.
U-Qtil>

but thats not what I want. I want the script to telnet to the processor then do ps and write the result in the result file then quits without giving me the output of telnet to type ps.

Can anyone help me regarding this, I will be so thankful.

Best Regards,
Ahmed.

Use rsh or ssh to execute a command on a remote server.

hi,

rsh and ssh are not working, for my case I have to telnet on a processor on a certain port.

I have one feedback regarding my case, is that after I run the script I get:
Trying 172.16.0.9...
Connected to 172.16.0.9.
Escape character is '^]'.
U-Qtil>

and then the ps command is done on the local server not the one I am telneting to. I want to do ps on the remote server and print its output in the result file on the local server.

BR,
Ahmed.

You may want to try something like this

The script is:
#!/bin/sh
cd /ahmed/ezzat/
rm ss7trace.log
touch ss7trace.log
chmod 755 ss7trace.log
telnet 172.16.0.9 8100 << !! > result
ps
quit
!!