LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-14-2007, 09:58 AM   #1
pandersson61
Member
 
Registered: Jan 2004
Distribution: Ubuntu 9.10, 10.04
Posts: 36

Rep: Reputation: 15
Expect script - No output to file


I'm using a expect script to connect to a mp3 server (irmp3d) via telnet and output a playlist. When i run the script from a bash shell the script works as expected and gets the playlist. But when i run the script from within the server all i get out of the script is the commands passed to the spawned telnet client. Does anyone have any idea on how to pipe the output from the telnet client to a file?

This is my script:
Quote:
#!/usr/bin/expect
log_file -a /home/mp3/telnet.log
set host [lindex $argv 0]
set port [lindex $argv 1]
spawn telnet $host $port
send "query plfiles\r"
send "exit\r"
When run through a regular bash shell the log looks something like this:
Quote:
220: plfiles: /music/Black Sabbath/Headless Cross/07-Black Moon.mp3
220: plfiles: /music/Black Sabbath/Headless Cross/08-Nightwing.mp3
But when i run the script through the mp3 server software all i get in the log is:
Quote:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
query plfiles
I have tried running the command:
Quote:
script 2%>1 /home/mp3/newlog.log
with the same results. Does anyone have any idea on how i can solve this? If so please let me know.

Thanks!

/Peter

Last edited by pandersson61; 05-14-2007 at 10:31 AM.
 
Old 05-14-2007, 12:32 PM   #2
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,438

Rep: Reputation: 52
Quote:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
query plfiles
Ummm, are you sure you are connecting to the mp3 server? I'm seeing a connection to 127.0.0.1 - which is your own box.

-twantrd
 
Old 05-14-2007, 12:57 PM   #3
pandersson61
Member
 
Registered: Jan 2004
Distribution: Ubuntu 9.10, 10.04
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by twantrd
I'm seeing a connection to 127.0.0.1
Thanks for the reply!
The script is meant to be run on the server to save the current playlist on the server when the mp3 daemon is shut down. So the localhost ip is correct.
I have solved the problems by using the "script -c [script] /output/to/file.txt" command, for some reason that worked but not expect...

/Peter

Last edited by pandersson61; 05-14-2007 at 01:00 PM.
 
Old 05-21-2007, 12:44 PM   #4
lexwoodrum
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by pandersson61
Thanks for the reply!
The script is meant to be run on the server to save the current playlist on the server when the mp3 daemon is shut down. So the localhost ip is correct.
I have solved the problems by using the "script -c [script] /output/to/file.txt" command, for some reason that worked but not expect...

/Peter
When you telnet you have to enter the login ID and password.
You must send those from the expect program.

Since you did not, it just echos whatever you sent it.

lexwoodrum
 
Old 05-23-2007, 05:18 AM   #5
pandersson61
Member
 
Registered: Jan 2004
Distribution: Ubuntu 9.10, 10.04
Posts: 36

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by lexwoodrum
When you telnet you have to enter the login ID and password.
Thanks for the reply! But the software running the telnet server doesn't require a login. You just telnet port 9232 (no username or password) and you get instant access. If i run the script from a normal bash shell the script works just fine. The problems occur when i run the script from inside the mp3 server software.

/Peter
 
  


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
cpu, mem, ps output to file script beeblequix Linux - Enterprise 3 09-08-2006 03:08 PM
Dvd:rip / transcode users: when you rip dvds, is the output file the size you expect? 144419855310001 Linux - Software 0 09-02-2006 08:56 AM
shell script output to file drum2jc Linux - Software 1 05-30-2006 06:54 PM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 03:40 AM
Expect script throws "open(slave pty): bad file number" error KNut Linux - Newbie 0 02-24-2004 12:24 PM


All times are GMT -5. The time now is 01:49 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration