Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

How to redirect STDIN from within a batch file?

  • 31-08-2002 11:31PM
    #1
    Banned (with Prison Access) Posts: 16,659 ✭✭✭✭


    Heh, it's not often I get to ask a question in here. And this is a really silly one:

    I have a command line exe called bzip (compression utility) in my windows directory, which has a switch (-d) to decompress a file. On Linux, you also have bunzip2, and I keep typing that in in Windows by mistake. So my question is: How do I redirect stdin from within a batch file?

    adam


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    hup


  • Registered Users, Registered Users 2, Paid Member Posts: 5,808 ✭✭✭jd


    I think it is..

    command < file Command gets standard input from file

    didn't try it though


  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    OK, not entirely following you, but maybe what you're looking for, is a second bunzio2 thingy like:

    bunzip2.bat
    bzip -d < %1
    

    where then you'd just type:

    bunzip2 input.txt

    I'm not sure if you can take '<' into account in a batch file.......but I'm going searching now... :D


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    That'll do it, but it prints to stdout. Hmmm...

    adam


  • Registered Users, Registered Users 2, Paid Member Posts: 5,808 ✭✭✭jd


    Originally posted by dahamsta
    That'll do it, but it prints to stdout. Hmmm...

    adam
    >output.txt


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    < = accept inputs
    > = display STDOUT to where ever
    >> = Display STDOUT appending to where ever.

    2> = Display STDERR to where ever
    2>&1 = Display STDERR to whatever STDOUT is set to.

    and you have append (>>) for STDERR as well.

    examples:

    command < %1 > null 2> errors.txt

    command < con: >> output.txt 2>&1


Advertisement