LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to send the output of send command to a file (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-send-the-output-of-send-command-to-a-file-857585/)

auma78 01-20-2011 12:25 PM

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?

szboardstretcher 01-20-2011 12:26 PM

Code:

/bin/bash script.sh -x > log.out

auma78 01-23-2011 12:06 AM

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 :)


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