Reputation: 3739
I'm trying to automate some work with an interactive program. Doing
SplitsTree +g
Starts the CLI interactive version of the program which I would normally then enter interactively:
EXECUTE FILE=Asexual_randomSub.nxs
UPDATE
SAVE FILE=output.network
QUIT
How can I feed these commands in? Simply copying the above 6 lines into a .sh file and executing it does not work.
Upvotes: 0
Views: 983
Reputation: 11
Passing the commands on via the -x parameter worked for me.
SplitsTree +g -x 'EXECUTE FILE=in.nex; UPDATE; SAVE FILE=out.nex; QUIT'
Upvotes: 1
Reputation: 72745
Often, many of these commands have a non interactive mode using which you can read in commands from a source file. This would be the preferred way.
Another option is to try to use a here document or pipe the inputs into stdin.
The third way is to use something like expect and manually do the whole input business. This is flaky but sometimes the only choice.
Upvotes: 2
Reputation: 798536
Heredoc.
#!/bin/sh
SplitsTree +g << EOF
EXECUTE
FILE=Asexual_randomSub.nxs
UPDATE
SAVE
FILE=output.network
QUIT
EOF
Upvotes: 1