LinuxQuestions.org
Help answer threads with 0 replies.
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 01-08-2010, 05:58 AM   #1
wtfman
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 0
Doesn't work: spawn cat <file> | ssh root@$ip mtd -r -e linux write - linux


Hi,

i'm going to write a script that flashes all AccessPoints in our network, with an expect script.

Unfortunately the following code doesn't work (:
Code:
spawn cat <file> | ssh root@$ip mtd -r -e linux write - linux
cat: invalid option -- o
Try `cat --help' for more information.

So it doesn't understand the pipe thing anymore.
Is there a way to get this command working? Thanks in Advance!
 
Old 01-08-2010, 06:15 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Does the file name start with a hyphen? If so, then use "spawn cat -- ..." instead. Also sometimes you need to put the command you want ssh to run inside quotes so that things like variables and redirections are evaluated on the remote server and not by bash on the client computer. note: unless that is what you want.

Last edited by jschiwal; 01-08-2010 at 06:16 AM.
 
Old 01-08-2010, 06:37 AM   #3
wtfman
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Original Poster
Rep: Reputation: 0
No, filename doesn't start with a hyphen:
Code:
cat bin/openwrt-brcm-2.4-squashfs.trx | ssh -o stricthostkeychecking=no -i wrt_key root@$ip mtd -r -e linux write - linux
This is actually working, but not with spawn...
 
Old 01-14-2010, 09:43 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You may need to quote everything after the spawn command. I'm not sure how the line would be expanded in expect. It may do things differently than bash.

Another option is to move the command into a script and spawn the script instead.

Last edited by jschiwal; 01-14-2010 at 09:45 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
Does "mtd write" clear/erase the end of the mtd block by default? (no man page found) maddes.b Linux - Kernel 0 08-17-2009 03:07 AM
cat file over ssh and put it into log file sinister1 Programming 2 04-24-2009 12:54 AM
Expect interpreter, spawn and cat Ricio Programming 11 08-16-2008 05:55 PM
ssh -> perl -> spawn background proces hangs ssh session rhoekstra Programming 2 04-25-2006 01:05 AM

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

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

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