LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-09-2007, 07:12 AM   #1
TB_205gti
LQ Newbie
 
Registered: Dec 2005
Posts: 20

Rep: Reputation: 0
Input from file to screen


Hi, I use screen to connect to /dev/ttyS0 to do some tasks via the COM port, but I need a script to do this. As it is now I have to manualle start screen and enter the commands I need to use, but how can I the contants of a text file to do this? I really need this in order to use some analysis scripts.

If it is not possible with screen, is it then possible with another tool? (bash, perl, python are welcome..)
 
Old 01-09-2007, 08:23 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
I'm not sure exactly what you're trying to say, but try this command at the shell prompt:

man expect

Hope this helps.
 
Old 01-09-2007, 09:44 AM   #3
TB_205gti
LQ Newbie
 
Registered: Dec 2005
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wjevans_7d1@yahoo.co
I'm not sure exactly what you're trying to say, but try this command at the shell prompt:

man expect

Hope this helps.

This is what I have been looking for

Next problem.. This is my simple expect input file..

spawn screen /dev/ttyS0
send "ATE"
expect "OK"
send "at+cmgf=1"
expect "OK"
exp_eof

Problem is that screen is started, but something goes wrong. The ATE command is sent just fine, but i never gets an "OK" and thus times out.

this is the output of expect -d [file]

expect: does "ATE\u001b[?1049h\u001b[r\u001b[m\u001b[2J\u001b[H\u001b[?7h\u001b[?1;4;6l\u001b[4l\u001b[?1h\u001b=\u001b[0m\u001b(B\u001b[1;39r\u001b[H\u001b[2J\u001b]2;[screen -] \u0007\u001b[H\u001b[2J\u001b]2;screen\u0007\u001b]2;[screen 0: ttyS0] \u0007" (spawn_id exp4) match glob pattern "OK"? no
expect: timed out
send: sending "at+cmgf=1" to { exp4 }

expect: does "ATE\u001b[?1049h\u001b[r\u001b[m\u001b[2J\u001b[H\u001b[?7h\u001b[?1;4;6l\u001b[4l\u001b[?1h\u001b=\u001b[0m\u001b(B\u001b[1;39r\u001b[H\u001b[2J\u001b]2;[screen -] \u0007\u001b[H\u001b[2J\u001b]2;screen\u0007\u001b]2;[screen 0: ttyS0] \u0007" (spawn_id exp4) match glob pattern "OK"? no
expect: timed out
invalid command name "exp_eof"
while executing
"exp_eof"
(file "in" line 6)

(I know about the eof error..)


If I enter the commands manually screenlog.0 gives this:

[bubba@jupiter ~]# cat screenlog.0

OK

OK

OK
[bubba@jupiter ~]#

But if I use expect, screenlog.0 is empty

Last edited by TB_205gti; 01-09-2007 at 10:42 AM.
 
Old 01-10-2007, 06:06 AM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
screen sends all sorts of cursor-related stuff to its output (in other words, to your screen and to expect). This complicates things if you're looking for a simple "OK". Try to find some other way to do this without using screen.
 
Old 01-10-2007, 08:42 AM   #5
TB_205gti
LQ Newbie
 
Registered: Dec 2005
Posts: 20

Original Poster
Rep: Reputation: 0
wjevans_7d1@yahoo.co: I use screen to connect to a nokia phone through a DLR3 cable. I'm used to screen, but if there are other applications with wich I can connect to the phone and send AT commands, they may be a better choice.
 
Old 01-11-2007, 07:02 AM   #6
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
I've just reread your original post. If your goal is to use analysis scripts, I'm hoping that you mean it's ok to do the analysis after the whole session is done, rather than in real time while the session is in progress.

If that is the case, don't use screen and don't use expect. Use minicom, and turn logging on. After the session is over, you'll have a clean file that just shows the traffic back and forth. You can use your analysis scripts on that.

Hope this helps.
 
Old 01-11-2007, 12:22 PM   #7
TB_205gti
LQ Newbie
 
Registered: Dec 2005
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wjevans_7d1@yahoo.co
I've just reread your original post. If your goal is to use analysis scripts, I'm hoping that you mean it's ok to do the analysis after the whole session is done, rather than in real time while the session is in progress.

If that is the case, don't use screen and don't use expect. Use minicom, and turn logging on. After the session is over, you'll have a clean file that just shows the traffic back and forth. You can use your analysis scripts on that.

Hope this helps.
Maybe my post isn't that clear English is not my mothers tonque

I have some scripts that log system specific "things" - I need to send a status sms via the Nokia phone I have atteched to the server.
Normally I use screen /dev/ttyS0 and the enter the AT commands in order to send a sms.
Now I want a script to be able to do that - sending a status sms automatically.
The reason I would use screen is that I can use that to send AT commands to the phone.
 
Old 01-12-2007, 06:10 AM   #8
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
Instead of using screen, you can use minicom to send AT commands to the phone.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Cannot input keystrokes, screen flashes blank nym Linux - Desktop 1 01-07-2007 01:53 AM
Installed SuSE 10.1 - Blank Screen, no Video Input. flatstan SUSE / openSUSE 13 12-21-2006 09:28 AM
IBM Thinkpad T40 - RHEL 4.0 - Screen goes black when no input exitsfunnel Linux - Laptop and Netbook 1 11-27-2005 01:17 AM
Mandrake linux 9.2 Screen goes blank + no response to user input micro_sucks Linux - General 2 03-01-2004 03:30 PM
Keyboard input not on screen g_rat Programming 1 03-27-2003 11:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:53 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