Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse Input Output Redirection with < and >
Eclipse Input Output Redirection with < and > [message #1781568] Thu, 08 February 2018 18:44 Go to next message
Brian Chu is currently offline Brian ChuFriend
Messages: 1
Registered: February 2018
Junior Member
So in the terminal, I can run my program with
./letter --stack -b ship -e shot -c --output W < input.txt > output.txt


How do I achieve the same functionality in Eclipse? I've figured out how to do --stack -b ship -e shot -c --output W by going to the arguments tab under Run configuration.

I've looked online and seen a lot of posts about using the Common tab to input and output redirection but I can't get it working. When I check only the input file, it doesn't work and the Debug perspective shows it's stuck somewhere trying to read from a stream. When I check allocate console and input file, then it gets stuck on user input (aka I can manually type stuff) in the console.

So how do I get < input.txt and by extension > output.txt working?
Re: Eclipse Input Output Redirection with < and > [message #1781590 is a reply to message #1781568] Fri, 09 February 2018 04:20 Go to previous message
David Vavra is currently offline David VavraFriend
Messages: 660
Registered: October 2012
Senior Member
Eclipse launches the command as a new process without using a shell.
You probably should execute a shell command that then executes your program
Under Linux, the following run configuration (note the command and arguments are in separate tabs):
/usr/bin/bash -c "pwd; echo 'pstree -a -s $$' > tmp;  bash -p < tmp"

produces
/home/dvavra/proj/HCP-FANN
systemd --switched-root --system --deserialize 23
  └─lightdm
      └─lightdm --session-child 12 19
          └─sh /etc/xdg/xfce4/xinitrc -- vt
              └─xfce4-session
                  └─xfce4-panel --display :0.0 --sm-client-id 26f5d9e4b-868b-48f5-a436-a94ab1f73c5b
                      └─eclipse
                          └─java -Dosgi.requiredJavaVersion=1.8 -Dosgi.instance.area.default=@user.home/eclipse-workspace ...
                              └─bash -c pwd; echo 'pstree -a -s $$' > tmp;  bash -p < tmp
                                  └─bash -p
                                      └─pstree -a -s 28855

Note that the first bash command (shown after java) is executed directly.
This double use of bash is only for illustration.
Executing bash -c 'pstree -s $$' causes the invocation of bash to vanish.
systemd --switched-root --system --deserialize 23
  └─lightdm
      └─lightdm --session-child 12 19
          └─sh /etc/xdg/xfce4/xinitrc -- vt
              └─xfce4-session
                  └─xfce4-panel --display :0.0 --sm-client-id 26f5d9e4b-868b-48f5-a436-a94ab1f73c5b
                      └─eclipse
                          └─java -Dosgi.requiredJavaVersion=1.8 -Dosgi.instance.area.default=@user.home/eclipse-workspace ...
                              └─pstree -a -s 29210


Under Windows you should execute cmd.exe /c "your command"

[Updated on: Fri, 09 February 2018 04:23]

Report message to a moderator

Previous Topic:Code completion does not work properly?
Next Topic:OpenCV Eclipse cant find include files
Goto Forum:
  


Current Time: Wed Feb 21 19:25:20 GMT 2018

Powered by FUDForum. Page generated in 0.01281 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software