Author Topic: Unable to set redirection in windows  (Read 4964 times)

Offline sd3969682

  • Single posting newcomer
  • *
  • Posts: 2
Unable to set redirection in windows
« on: January 15, 2012, 09:35:22 am »
I have a really annoying problem.
When I using codeblock in windows and setting the program's arguments such as:
-someCommand <input.txt >output.txt
The redirecting just doesn't work!
It still ask me to input from my screen(keyboard), but not from the file.
However, it does work in DOS or even codeblock in ubuntu.
I intend to programming in windows. Thus, anyone who can help? :-[

zabzonk

  • Guest
Re: Unable to set redirection in windows
« Reply #1 on: January 15, 2012, 08:24:17 pm »
That's because they are the program's arguments, not the shell's. In other words, the redirection characters are simply passed to the program as part of the argc/argv parameters. I'm surprised it works on Ubuntu though.

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Unable to set redirection in windows
« Reply #2 on: January 15, 2012, 08:40:42 pm »
A workaround would be to to have Code::Blocks execute your command in a post-build step or a commands only target, or if that does not work, write a batch file with your command in it, and have Code::Blocks execute the batch file.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Unable to set redirection in windows
« Reply #3 on: January 15, 2012, 10:01:01 pm »
A workaround would be to to have Code::Blocks execute your command in a post-build step or a commands only target, or if that does not work, write a batch file with your command in it, and have Code::Blocks execute the batch file.
Even easier: Make use of the toll.s menu and it's associated macros.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline sd3969682

  • Single posting newcomer
  • *
  • Posts: 2
Re: Unable to set redirection in windows
« Reply #4 on: January 15, 2012, 10:24:23 pm »
A workaround would be to to have Code::Blocks execute your command in a post-build step or a commands only target, or if that does not work, write a batch file with your command in it, and have Code::Blocks execute the batch file.
Even easier: Make use of the toll.s menu and it's associated macros.
Oh! I found that. But I'm new with that and don't know what to do.
Can you give me a simple example? Thanks a lot!

Also thanks Neil and alpha!

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Unable to set redirection in windows
« Reply #5 on: January 15, 2012, 11:13:39 pm »
Even easier: Make use of the toll.s menu and it's associated macros.
Oh! I found that. But I'm new with that and don't know what to do.
Can you give me a simple example? Thanks a lot!
Try the Tools+ reference.