0

I was writing a bash-script which communicate with a server via telnet, but right now I need to evaluate the reply from server.

Usage:

./edit.bash | telnet

BASH script:

echo "open ip port"
echo "login user pass"
echo "select 1"
echo "me"
echo "edit id=ID group=3"
echo "exit"

If I send the command "me" I get a reply from the server which i need to evaluate.

The reply from server looks like this example... "nick=NICK id=ID group=GROUP login=LOGIN".

A friend of mine told me that I need to look for "expect" than "bash", but my knowledge of expect is right now ZERO :p

Never used that before...

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
am1
  • 345
  • 1
  • 2
  • 13
  • 1
    You will generally get better answers here if you first try things out yourself. Go read about `expect`, try writing some scripts, and if things don't work you can come here with specific examples. – larsks Sep 13 '14 at 22:08
  • Have a look at http://stackoverflow.com/questions/11250564/how-to-automate-telnet-session-using-expect?rq=1 – Dinesh Sep 14 '14 at 03:16
  • Ok i converted my script to a expect-version, but the comment-function doesn't give me a good reply-function so i created a new stack-entry: [link](http://stackoverflow.com/questions/25922547/linux-telnet-script-with-expect) – am1 Sep 18 '14 at 21:24
  • Good set of tutorials for expect: http://wiki.tcl.tk/11584. Go through them. Also, if you decide to go down the expect path learn a bit about tcl (it's the language expect scripts are written in). – slebetman Nov 26 '15 at 02:12

0 Answers0