LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 08-04-2008, 09:41 PM   #1
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Rep: Reputation: 30
Expect interpreter, spawn and cat


Hello all,

when I try to execute cat next to a spawn I get an error...

What im trying to do is the following:

Code:
spawn cat ~/.ssh/id_rsa.pub | ssh user@remote "cat - >> // .ssh/authorized_keys"
With this one the error states | no such file or directory
ssh no such file or directory, as if everything from | and forth were dirs or files

and with

Code:
cat ~/.ssh/id_rsa.pub | spawn ssh user@remote "cat - >> // .ssh/authorized_keys"
Error here is invalid command name "cat"

Can anyone explain to me why this happens... could you help me out!?

Thank you
 
Old 08-04-2008, 09:42 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
It would be easier to spawn a ssh-copy-id process instead of ssh.
 
Old 08-05-2008, 10:49 AM   #3
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Original Poster
Rep: Reputation: 30
mmm... did not know about ssh-copy-id, mmh, I guess I have lots of studying to do to get LPI I and II certified!


Ill try it tonight and tell you how it went, and matthewg, thank you again!
 
Old 08-05-2008, 12:31 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
I think it is actually just a script, but it will handle the redirection for you. Probably the direct approach doesn't work because the re-direction is messed up because of confused quoting.
 
Old 08-05-2008, 05:36 PM   #5
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Original Poster
Rep: Reputation: 30
If I were trying to run this from a kickstart postscript, would it run??

i know I had to do --interpreter=/usr/bin/expect -f and nochroot, could I use several interpreters in the kickstart post scripts?
 
Old 08-05-2008, 05:38 PM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
What is a kickstart postscript?
 
Old 08-05-2008, 05:45 PM   #7
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Original Poster
Rep: Reputation: 30
umm... I mean as a postscript in a kickstart installation, like redhat kickstart...
 
Old 08-05-2008, 07:41 PM   #8
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Original Poster
Rep: Reputation: 30
from what version of openssh does the ssh-copy-id script comes in the package!? cuz It seems like I dont have it install...
 
Old 08-06-2008, 05:31 AM   #9
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
It's in the package "openssh-client-1:4.7p1-8ubuntu1.2" in Ubuntu.

If you don't have it, then you might just write a shell script of your own to do the copy. Here's what's in the official ssh-copy-id (link).

I think your original problem is that you are using the pipe as if spawn is a shell command, and thinking expect has the same functions. Expect is not like a shell script interpreter - it uses a language called TCL. AFAIK, TCL has no concept of pipes and re-direction (at least not in the same way that shell scripting does).
 
Old 08-06-2008, 11:29 AM   #10
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Original Poster
Rep: Reputation: 30
mmm... I was doing that exactly assuming expect as a bash like interpreter, but then I have a problem, see the point is to get this script run as a postinstallation process in order to allow them automatically to ssh without password to the server at the end of installation and ask the pull some files from the server automatically, cant use netcat since netcat only allow for a single connection at a time right??

What could I try in order to achieve this!?

I have not tried spawning ssh-copy-id but ill try tonight or tomorrow.
 
Old 08-06-2008, 01:18 PM   #11
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
To pull some files down from a server on the net somewhere, you don't need to use ssh/expect at all - why not just use curl or wget or something which can pull files using HTTP/HTTPS or FTP?

All these protocols can use password authentication if you want the files to only be available to your customers, and if you want to keep the transfer from being snoopable by third parties who share a network with you, use HTTPS.
 
Old 08-16-2008, 05:55 PM   #12
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Original Poster
Rep: Reputation: 30
As always thanks matthewg42, got a webserver running and downloaded all the files succesfully!

Thanks again!
 
  


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
Unexpected curly braces in expect script spawn command & bash suid problem slinx Programming 1 05-02-2008 01:47 PM
expect -c "spawn ls" The system has no more ptys status1 Linux From Scratch 12 03-29-2008 08:51 PM
expect -c "spawn ls" Problem ravi.xolve Linux From Scratch 1 05-07-2007 11:10 AM
cat in asm/ cat --show-all option Tux Linux - Software 1 09-02-2006 09:31 PM
error in 6.13 binutils~ expect -c"spawn ls" sharmashikha Linux From Scratch 1 06-21-2005 11:53 AM


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