I want to run the following commands in bash script form in Solaris 10:
$ telnet localhost 25 debug quit
How do I handle this?
If you have any luck with having bash configured with
--enable-net-redirections, Bash's special redirections might be useful:
cat <<EOF >/dev/tcp/localhost/25 debug quit EOF
When you're also interested in the output from the server:
exec 3<>/dev/tcp/localhost/25 # open localhost:25 as fd 3 cat <<EOF >&3 # write to fd 3 debug quit EOF cat <&3 # read from fd 3 exec >&3- # close fd 3
Edit: as per sugested, and after testing, this work on linux, but not on solaris as OP request.
(echo debug ; echo qui ) | nc localhost 25
or (heredoc style)
nc localhost 25 <<EOF debug quit EOF
on my ubuntu, telnet do not take input, while netcat does.