Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can't find anywhere that addresses this, and I can't find a way to do it. I've got an app that I've written and I want to be able to call an app and pass it a script, and it works fine with it in a script file, but ideally I'd prefer to keep the script in the code and out of a file in readable (and easily screw-upable) form. Is there a way to pass a set of instructions to cmd like this, or is a temp file the only way?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The < redirection can be replaced with a pipe:

echo foo; bar; | cmd.exe

You can group commands:

(echo foo
 echo bar) | cmd.exe
share|improve this answer
    
This works. I'll accept in a sec.. for some reason it says I have to wait two minutes. –  trycatch Mar 31 '11 at 20:19

It depends on the app that you're using. Many will have the ability to take the script commands directly on the command line, others will have the ability to take stdin directly as the script you want to run. You need to look at whatever user's guide there is for the specific app you're trying to invoke to figure out which method you need to use.

If the app has no method except taking in a file, then barring some complex magic with file descriptor pipes that's way above my head (and far more complex than simply using a file) you're out of luck I'm afraid.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.