Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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 Posts: 5,717 ✭✭✭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,317 ✭✭✭✭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 Posts: 5,717 ✭✭✭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