suppose i have a perl script that is normally run this way:
./checkdisk.pl -H hostname -w 40 -c 80
but, for whatever reason, i cannot run the script directly as it should. But i can cat it through pipe. How can i pass the arguments "-H hostname -w 40 -c 80"?
so this is what i'm doing, which is clearly not going to work:
$ echo 'echo asdf $1 $2 $3'
asdf $1 $2 $3
# For bash scripts, sh -s arg1 arg2 arg3 ...
# Be sure to use the appropriate shell, bash for bash scripts,
# ksh for ksh scripts, etc.
$ echo 'echo asdf $1 $2 $3' | sh -s a b c
asdf a b c
# For perl scripts:
$ cat script.pl | perl - arg1 arg2 arg3 ...
Also, I should note, there's an important difference between running scripts like this and running them from a file: When you run from a pipe, stdin will not be a keyboard. So if any of these scripts are interactive, that may be a problem.