I need some help on using a file with the cat command. I want to set up a telnet connection with a network device with the ip-adress 10.3.0.1. Just executing the command 'telnet 10.3.0.1' gives a menu. For example, to show the help of the menu, you need to type '?'.
Now I want to go through the menu with commands (like '?') that are in a file. For this I want to use the command:
cat filename | telnet 10.3.0.1
When I try this, the telnet connection is established, but then it closes immediately afterwards. So I suppose something's wrong with the file. But I have no idea what the file should look like. For example, do you need to mention the enters after a command in a certain way?
just to be clear: the command in the menu that I want to execute are:
"?" -> enter
"projector" -> enter
"exit" -> enter
It may be inputting the data and finding EOF before it even gets to the menu. The expect tool is often used to automate interactive prompts like this, since it can be told to wait for responses or prompts before sending data.
Location: meri jaan Mumbai, from mera desh BHAARAT.
Posts: 147
Thanks Given: 7
Thanked 15 Times in 15 Posts
To make a shell script which can telnet automatically and run commands on the other machine and end the telnet session without any interaction from the user, you need to install EXPECT and TCL packages on your unix system.
If you are done with above mentioned then, you can write a script similar to following (as per your requirements) :
to execute this script, you can type:
but before u call the expect script, you should make the expect script executable, and this can be done by typing:
You can also call the above script from any other script....
Hi Team,
Not getting the file output inside my email which i am sending from unix box. . Please refer the below code :
#!/bin/sh
{
sleep 5
echo ehlo 10.56.185.13
sleep 3
echo mail from: oraairtel@CNDBMUREAPZP02.localdomain
sleep 3
echo rcpt to: saurabhtripathi@anniksystems.com... (1 Reply)
Team,
we use below command to store the contents in a logfile.
cat a.txt > a.log
a.txt content is
123
345
Is there any options available to store the command used also?
for eg a.log may show as
cat a.txt
123
345 (5 Replies)
cat myname.txt
John Doe I
John Doe II
John Doe III
-----------------------------------------------------------------------
for i in `cat myname.txt`
do
echo This is my name: $i >> thi.is.my.name.txt
done
-----------------------------------------------------------------------
cat... (1 Reply)
Hi there,
Can show some hit why i got this error?
For eg i have a.txt in which consist of contents as below
1|781494-0015|IV\|I||C|RECHARGE|Success\|V\|\||2007-12-04 02:33:13.000|
2|762405-0405|IV\|I||C|RECHARGE|Success\|V\|\||2007-12-04 02:33:17.000|
In fact , i want to perfrom to have... (2 Replies)
Hi All,
I need to stop all the services for telnet & FTP as we want our
server to be more secure.
Please give me some steps for jumping to SSH protocol.
How can i disable telnet & ftp service on my server. (1 Reply)
Hi,
Any scripting experts out there that can point me to the right direction of writing a script using telnet and su to access a server without any users interaction such as login and entering passwd. Thanks.
Thanks in advance
vastare (1 Reply)