开发者

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜