LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problems with Process Substitution and scp - Solaris to Linux (https://www.linuxquestions.org/questions/linux-newbie-8/problems-with-process-substitution-and-scp-solaris-to-linux-587815/)

sdduuuude 09-27-2007 02:47 PM

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?

chrism01 09-28-2007 12:04 AM

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

sdduuuude 09-28-2007 10:34 AM

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"

matthewg42 09-28-2007 10:47 AM

You could also do it like this:
Code:

ssh user@server cat /home/user/file.txt


All times are GMT -5. The time now is 10:31 PM.