How to send parameters to a batch file

test.bat parm1 parm2 parm3
I am using .bat commands to execute Curl commands for Twitter API
Sample Output
set myparm1 =%1
set myparm2 =%2
set myparm3 =%3
echo %myparm1% %myparm2% %myparm3%

By: lansa
2009-03-25 12:27:18

These Might Interest You

  • If shell escaping of the command is problematic, you can write the command to a file first: batch <somefile Or read it: read -re && echo "$REPLY" | batch Or, if your shell supports it, you can eliminate echo: read -re && batch <<<$REPLY ("man batch" lists 1.5 for me, but I don't know how widely it differs.)

    echo 'some command' | batch
    kniht · 2010-07-14 03:08:31 0
  • there is no explicit find command in DOS you can create a batch file with this one and find all jpegs on the C drive ... note: if creating a batch file "find.bat" the syntax changes to: for %%f in (c) do dir %%f:\%1 /s /p you can then use find *.jpg Show Sample Output

    for %f in (c) do dir %f:\*.jpg /s /p
    copremesis · 2009-05-05 18:28:18 4
  • running top command in batch mode. it is usefull if you want to redirect the output in a file. Show Sample Output

    top -b -n 1
    r00t4u · 2010-01-24 16:17:30 1
  • This is a command to be used inside of MS-DOS batch files to check existence of commands as preconditions before actual batch processing can be started. If the command is found, batch script continues execution. If not, a message is printed on screen, script then waits for user pressing a key and exits. An error message of the command itself is suppressed for clarity purpose. Show Sample Output

    <command> >NUL 2>&1 || ( echo <Command> not found. Please install <command> or check PATH variable! & pause & exit )
    Marco · 2011-03-07 14:27:42 2

What Others Think

a) Windows is not unix. b) What exactly are we supposed to glean from this? The fact that basic commandline features work on windows? What exactly is good or informative about this? c) Good for you to use .bat files. Really. Why is that relevant to us?
ozymandias · 481 weeks and 6 days ago
click · 481 weeks and 5 days ago
I voted it down, not because it's a Windows command, but because the contents of test.bat aren't known, and the description mentions using the Twitter API, but doesn't give a valid example of the usage.
atoponce · 481 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: