LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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
 
LinkBack Search this Thread
Old 09-27-2007, 02:47 PM   #1
sdduuuude
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Rep: Reputation: 0
Problems with Process Substitution and scp - Solaris to Linux


OK, this isn't quite a newbie question, but I put it here in case I am missing something simple.

I have passwordless ssh all set up with public keys copied into the authorized_keys files as needed.

I am trying to copy the output of a script to a file on another server using scp. One server is Debian Linux. The other is Solaris.
The problem occurs in both directions.

In my test, the testScript simply echos "hello world" as such:
$ sh testScript
hello world

The command I use is:
$ scp <(sh testScript) user@remoteServer:/home/user/file.txt

The error I get is
/dev/fd/63: not a regular file

Why not workie ?!?!?

This works with no problems:
$ cat <(sh testScript)
hello world


Some more info: When I redirect the scp output to the cat command using process substitution, it kind of works, but there is an error message that I don't understand:
(the file junk.txt contains the text "junk on SD1")

$ scp user@remoteServer:/home/user/stuff/junk.txt >(cat)
junk.txt 100% 14 0.0KB/s 00:00
junk on SD1
/dev/fd/63: truncate: Invalid argument


How can I get scp to be process-substitution-compatible?
 
Old 09-28-2007, 12:04 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994
scp copies only files. Try something like

sh testscript>test.out && scp test.out user@remoteServer:/home/user/file.txt

for the first one.

It's not clear what/why you are doing the 2nd scp, but this might work:

scp user@remoteServer:/home/user/stuff/junk.txt |cat
 
Old 09-28-2007, 10:34 AM   #3
sdduuuude
LQ Newbie
 
Registered: Oct 2005
Posts: 4

Original Poster
Rep: Reputation: 0
I was doing the second scp just to see if I could use process substitution with scp in the second parameter. It was for curiosity only.

I do not want to use sh testScript >> file.txt because I want to avoid writing to disk. The output of testScript is pretty large.



A friend showed me the way, using ssh:
sh testScript | ssh user@server "cat > out.txt"

or, to first compress:
sh testScript | gzip -9 | ssh user@server "cat > /home/user/file.gz"
 
Old 09-28-2007, 10:47 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
You could also do it like this:
Code:
ssh user@server cat /home/user/file.txt
 
  


Reply

Tags
process, scp, substitution


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SCP as a background process Edmunds Linux - General 4 12-31-2006 12:20 PM
Bash Process Substitution joshholt Programming 4 10-11-2005 03:15 AM
process substitution jk3us Linux - Software 1 12-02-2004 04:34 PM
scripting a find, cp and bzip2 then scp process onewhoknows Linux - Newbie 2 06-08-2004 06:05 AM
help!help!about process on solaris winwar Programming 1 10-25-2003 08:46 AM


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

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