Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Automating input for interactive programs through C-script

Jun 28, 2012 9:32AM PDT

Hey all,

I'm a computational chemist trying to automate a bunch of the mundane calculations that I have to run on a daily basis. I've succeeded to a point, but there's just one problem that I'm running into:

I've successfully created a c-script (.csh) to automate one of the more tricky calculations that I have to run regularly, but part of this computation involves an interactive program that requires input from the user. The input that I need to give is very systematic, and I was wondering if there was a way to automate (i.e. specify the input in the script) the input into this program?

Any help of this would be great!

Thank you!

Discussion is locked

- Collapse -
Answer
Absolutely.
Jun 28, 2012 9:43AM PDT

You can go get Visual Basic Express and code up a SIMPLE APP to press the buttons for you.

Hint? Look at the SendKeys() function.
Bob

- Collapse -
No Buttons
Jun 28, 2012 10:09AM PDT

This is all command line input, no buttons to press

- Collapse -
And you bet.
Jun 29, 2012 9:14AM PDT

SendKeys() is just the beginning. I can automate command lines too.

Not to upset you but did you try this? Did you research how you could launch a command shell and then that command?

Bob

- Collapse -
Re: buttons and keys
Jul 2, 2012 5:43PM PDT

As the name says, sendkey sends keys, just like you press them.

But you can also write the input the program expects to a file, then run the program with input redirection to read from that file.

Kees