Linux bash script for telnet connection
Hello,
I'm looking to make a bash script that connects with telnet running a command on the remote server and retrieve the file created (It has limit, I can open a ftp connection to retrieve the file behind). And more information is passed as parameter of the program:
Code:
test_prog.sh <serveurdist> <login> <passwd> <deb>
I have it but it does not work (I think I'm missing the options to connect directly without requiring authentication to connect to the server. Any help regarding this will be appreciated. Thank you.
Re: Linux bash script for telnet connection
Tip to execute a command on a remote server, when that was accessible from a telnet but can not want to put services (rlogin, rsh, rexec) in place
on the remote server.
1) Make a script containing the transactions would be done manually
by telnet. (Example Script action.scr "below)
Code:
# / Bin / sh
sleep 2
echo "user connection"
sleep 1
echo "password"
sleep 1
echo "command 1"
sleep 1
echo "No Control"
sleep 1
echo "exit"
Note (1): The "sleep 1" is important on Linux platforms otherwise the script is too fast is the telnet sees not pass the instructions. Increase the value of sleep following the order if it a long delay in reply.
Note (2): Do not forget to put the rights of execution on the script (chmod 777 action.scr)
2) Then run the script redirects to the telnet
Example:
Code:
Action.scr # sh | telnet IPaddress
Result: telnet connection with enforcement of orders 'echo "order"'
script "action.scr" (as manual way ").
Re: Linux bash script for telnet connection
The problem I have for the moment that it can not authenticate correctly. I manage to access the server, but it puts me directly after the remote server terminated the connection (it does not even that). Otherwise like find walking very well, I already tried everything in hand and everything works.
Re: Linux bash script for telnet connection
I proposed to the rexec instead of your telnet:
Code:
rexec [username @ hostname] [-DNN] [-l username] [-p password] command
And command, you put
Code:
"Cd $ 4; find.-Type d-exec echo () \;> arbo.txt"
This should work. Do not worry about not being noticed you just go with your code.
Re: Linux bash script for telnet connection
Even i have a similar kind of a issue with my script, well then I tried in every way - in case I made a mistake - I checked what I typed several times and I read the man with extensively.
So I have this code:
Code:
echo "test" root @ sertst rexec-l login-p passwd "find.-type> arbo.txt" echo "End Test"
But it asks for more password and answer me this:
Code:
Password: rexec: Error in rexec system call rexec: (The system error FOLLOWING Itself May Be in error) rexec: Success
I have no idea regarding this error, if you can help me with this it would be great.
Re: Linux bash script for telnet connection
Hello,
I know that I tried to telnet like this and finally I am back on the rexec. But I think there are limitations and different versions of the OS according to rexec, including the fact of passing the password parameter. I guess I am correct here and you have understood what I am trying to say.