LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-14-2016, 10:57 AM   #1
whatsup
LQ Newbie
 
Registered: Mar 2016
Posts: 4

Rep: Reputation: Disabled
Expect Script to automate Telnet login and Logs to File and Print Output.


Hi I am try to get an expect script to telnet and login to a Panasonic and collect the call log to a file and print the new lines as calls are completed.
I am able to login successfully and write call to a log file, but can not print the output.

#!/usr/bin/expect
#!/home/pi/Documents
spawn telnet
expect "telnet>"
send "open 192.168.0.101 2300\r"
expect "Connected to 192.168.0.101."
send "\r"
expect "*"
send "smdr\r"
expect "Enter Password:"
send "pccsmdr\r"
log_file telnetlog.txt
# timout while testing
set timeout 60
#will never match
expect "salmon*"

Thanks in Advance

Last edited by whatsup; 03-15-2016 at 09:46 AM. Reason: add addiy
 
Old 03-14-2016, 11:32 AM   #2
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Need to use code tags, so its easier to read, like this

Code:
echo "hello world"
Why Telnet? Unless you don't care about security...
 
Old 03-14-2016, 11:36 AM   #3
whatsup
LQ Newbie
 
Registered: Mar 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
Sadly that is what Panasonic use, so I am stuck with it. Only gives read access, no command access.

Cheers
 
Old 03-14-2016, 11:42 AM   #4
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by whatsup View Post
Sadly that is what Panasonic use

Cheers
So Panasonic doesn't care about security.

What type of output does it need to display?
 
Old 03-14-2016, 11:50 AM   #5
whatsup
LQ Newbie
 
Registered: Mar 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
on initial connection you get the header
Date time Ext
When a caller make a phone call you get a line a single line output
14/03/16 01:46PM 202 08001234567

This is all logged to my file fine, but no printout.
 
Old 03-15-2016, 09:51 AM   #6
whatsup
LQ Newbie
 
Registered: Mar 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
I am looking to leave the telnet open for 12hr and print any new line as they appear on a usb epson receipt printer.
Can I run an expect match and send line to printer or should I be looking to print from the capture file. Going round in circle as not sure what the best approach is.
Cheers
Whatsup
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Print an expect script output studym Linux - Newbie 3 01-04-2012 06:06 PM
Shell Script Commands to Automate Server or Host Telnet Login Session jakesjohn Linux - Software 4 02-08-2010 11:32 PM
Shell Script Commands to Automate Server or Host Telnet Login Session jakesjohn Linux - General 2 02-08-2010 11:28 PM
SHELL SCRIPT to automate telnet login rahulruns Programming 4 06-27-2009 06:11 AM
how to automate telnet login, script or something kiwibird Linux - Networking 2 11-09-2005 02:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration