Redirect text into a script that typically accepts file redirects
We have a custom script that we can run by redirecting a temporary file to that script...
i.e.
Step 1
BASH#echo 'commands' > file
Step 2
BASH#script < file
Is there a way to simplify the process to only one step... and directly send the commands to the script without the use of the temporary file?
I have attempted to do the following:
B开发者_运维问答ASH# script < echo 'commands'
BASH# script < 'commands'
BASH# script < "commands"
But I always get a message that it cannot find the file specified...
Any help would be much appreciated
Have you tried just
echo 'commands' | script
?
You can also use a here-document:
script <<END_COMMANDS
commands
END_COMMANDS
Or if you only need to send one line (and are using bash):
script <<<"command"
精彩评论