Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-20-2011, 01:25 PM   #1
LQ Newbie
Registered: Jan 2011
Posts: 10

Rep: Reputation: 0
Question how to send the output of send command to a file

in the middle of script, i need to send the output of (send command on line 8) to a file

spawn telnet
expect "ENTER USERNAM <"
send "user\r"
send "password\r\r"
expect "<"
send "show command; \r"
expect "<"
expect eof

i treid the below on line 8 :
1- send "show command; \r" > logfile.txt : gives an error extra character after the "
2- logsave logfile.txt 'send "show command; \r" ': error invalid command
3- i simply tried to send the output of the whole script to file logsave /home/logfile ./script : seems that logsave work under root only
4- ./script > logfile : the problem with this is that the output of echo or (read "enter your id") command will not be displayed on the screen (actually nothing will be displayed, i have to open the log file to see the output).
is there any way to save the log of the "send" ? or to save the log of the complete script without hiding the output on the screen?
Old 01-20-2011, 01:26 PM   #2
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,986

Rep: Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457Reputation: 1457
/bin/bash -x > log.out
Old 01-23-2011, 01:06 AM   #3
LQ Newbie
Registered: Jan 2011
Posts: 10

Original Poster
Rep: Reputation: 0
still not working, i cannot see any output from any "echo" inside the script on the screen. however, i get the string after (read -p "enter you id")even without the -x

Last edited by auma78; 01-23-2011 at 01:12 AM.


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
how to send the output of a command in a file defined by a eval $"$var1" toordog Programming 3 07-07-2010 05:26 PM
Send command to VLC and record output. ebasi Linux - Software 1 11-04-2009 06:40 PM
How to send command output to file?! mr_aliagha Linux - General 2 02-27-2009 02:06 PM
Send file output to 'kill' command jkarp2112 Linux - Newbie 4 06-25-2008 06:17 PM
IS it possible to send command output to a file as well as the screen helptonewbie Programming 6 09-16-2007 02:13 PM

All times are GMT -5. The time now is 08:17 AM.

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