Eddy Hernandez
Eddy Hernandez

Reputation: 5856

Redirect stdin script with parameters

I'm trying to do redirect the stdin to the ssh on a server, but the script contains parameters.

I'm doing this inside a Makefile

./docker-machine ssh machine < scripts/provision-docker-images.sh "param1" "param2"

I tried many options like

 < $(scripts/provision-docker-images.sh "param1" "param2")
 <(scripts/provision-docker-images.sh "param1" "param2")

any idea?

Upvotes: 0

Views: 930

Answers (1)

John Bollinger
John Bollinger

Reputation: 180181

The mechanism for connecting the standard output of one command to the standard input of another command is the pipe. The shell's operator for that is |. If I understand correctly that

  • the script is supposed to run on the local host
  • docker-machine ssh will forward its own standard input over the ssh connection to the remote shell

then what you want would be

scripts/provision-docker-images.sh "param1" "param2" \
    | ./docker-machine ssh machine

(line splitting optional).

In contrast,

  • the redirection operator < is for redirecting a command's standard input to come from a file;
  • the command substitution operator $(...) is for expanding the output of a command to form part of another command (similar to parameter expansion);
  • the process substitution operator <(...) is for creating a file name from which the output of a command can be read (i.e. designating the read end of a FIFO).

Upvotes: 1

Related Questions