Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-27-2007, 03:47 PM   #1
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, 01:04 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,329

Rep: Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745
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, 11:34 AM   #3
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, 11:47 AM   #4
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

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


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

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

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration