LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 12-03-2009, 11:44 PM   #1
dbdbdb
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
expect - can't use ">>" (append) in send command?


hi,

I am using Expect to login with ssh..
thats ok..

after login, I tried to append a text to a file.

my code:
Code:
...
<ssh login>
...
send "echo $textvalue >> file.txt\r";
but the $textvalue does not appended on file.txt

what's wrong with the code?


thanks!
(sorry for my english)
 
Old 12-04-2009, 11:26 AM   #2
dbdbdb
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Original Poster
Rep: Reputation: 0
I also tried with "spawn" command instead "send"
but it does not work anyway

there's another way to append string to file in expect script?


thanks
 
Old 12-05-2009, 09:36 AM   #3
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
You might need to provide more of your script. The section you have shown here is not the cause of the problem. The send command merely sends the characters to the spawned process, so the redirection characters are not treated any differently.

For example, the following script successfully appends a string to a remote file (I am using '$' to match prompts, and the ssh is done through identity files to simplify the script):

Code:
#!/usr/bin/expect
set textvalue abc
spawn ssh server
expect "$"
send "echo $textvalue >>file.txt\r"
expect "$"
send "exit\r"
expect eof
What does your script display when it executes? Does it even execute the echo command? You can capture the output using the following:
Code:
expect yourscript &>expect.out

Last edited by neonsignal; 12-05-2009 at 09:40 AM.
 
  


Reply



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
[SOLVED] Using an expect Script to send the output of cat and append it to a file spoofedexistence Programming 1 09-29-2009 03:50 PM
EXPECT/TCL: the "source" command and passing arguments qmqmqm Programming 4 04-02-2009 05:36 PM
My "expect" script is not working... Won't "send" commands... edomingox Programming 4 04-02-2009 03:25 PM
lrz won't send files, command line "gummed up" odat Linux - Software 0 05-23-2004 04:35 PM
Where is "append" command satimis Debian 11 01-02-2004 10:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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