Reputation: 510
I am writing a script in bash (on Linux) and I need to send some commands to a command line interface but I don't know how to do it.
To open the CLI :
myserver# ovirt-shell [options]
Then I'm in a new shell where I execute some commands to get back informations :
[oVirt shell (connected)]# list hosts > hosts.txt<br>
[oVirt shell (connected)]# list vms > vms.txt
So I would like to execute ovirt-shell and send my commands (list vms/hosts) directly in my script, in "silent-mode".
How can I do this ?
Upvotes: 2
Views: 6251
Reputation: 158040
Since the program reads from stdin, you can pipe the commands to stdin:
ovirt-shell <<EOF
list hosts
list vms
EOF
An alternative is to store the commands in file and execute it like this:
ovirt-shell -f filename
Upvotes: 4