LinuxQuestions.org
Register a domain and help support LQ
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 01-20-2011, 12:25 PM   #1
auma78
LQ Newbie
 
Registered: Jan 2011
Posts: 10

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


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

#!/usr/bin/expect
spawn telnet 172.20.64.133
expect "ENTER USERNAM <"
send "user\r"
expect "ENTER PASSWORD <"
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, 12:26 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,274
Blog Entries: 1

Rep: Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056Reputation: 1056
Code:
/bin/bash script.sh -x > log.out
 
Old 01-23-2011, 12:06 AM   #3
auma78
LQ Newbie
 
Registered: Jan 2011
Posts: 10

Original Poster
Rep: Reputation: 0
hi
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 12:12 AM.
 
  


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


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