0

I have to open up a command-line program and type in the following commands

 # From the command-line
 $ ./console.sh

 Welcome to Super Awesome Program 1.0 that I didn't write!
 Type 'help' to see all the commands supported.

 > some_command1 arg1
 Done.
 > some_command2 arg2
 Done.
 > some_command3 arg3
 Done.

 ...

 > some_command100 arg100
 Done.

Obviously I don't want to write a hundred of these commands. Is there an automated way to do this?

I tried

echo "some_command3 arg3" | ./console.sh

But that didn't work.

In general, is there a nice way to do this?

EDIT: A lot of the comments asked me to look at "console.sh". I looked at it and it seems like "console.sh" is just a wrapper for Java binaries. Here is the gist of "console.sh": https://gist.github.com/anonymous/0c1d9b05b94f3960f058

3
  • 1
    Since "console.sh" is apparently a shell script, your easiest option is to open it and look at it's innards. Then customize to your liking. Commented Jul 11, 2014 at 22:28
  • As we don't have console.sh, it's pretty hard to determine whether it will accept input like you're wanting. But you have the source to console.sh, so you can look to see how it works and whether it will do what you'd like it to do. Commented Jul 11, 2014 at 22:32
  • it would be much easier to write a simple c/c++ command line program, you don't need to know a lot to do it. Commented Jul 11, 2014 at 22:37

1 Answer 1

1

You should definitely use xargs

for your specific case - it's:

    echo "some_command3 arg3" | xargs -I {} ./console.sh {}

you can read more about xargs here http://linux.about.com/od/commands/a/Example-Uses-Of-The-xargs-Command.htm and in man xargs

if you want to execute hundreds of commands+arguments - you better first store them in some file and then use it as input to xargs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.