1

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?

Brian
  • 53
  • 5
  • 'Standard Input and Output' section on 'Common' tab. Check 'Input' and browse to your file – LMC Jan 30 '18 at 14:40
  • Already did that as noted in the question. – Brian Jan 30 '18 at 14:49
  • check second answer here https://stackoverflow.com/questions/188547/eclipse-reading-stdin-system-in-from-a-file/188654 – LMC Jan 30 '18 at 15:10
  • What part of the second answer are you talking about? The first half is outdated. The second half complete changes the program interface. – Brian Jan 30 '18 at 15:19
  • `${resource_loc:/MyProject/file}` does not work for you? – LMC Jan 30 '18 at 15:21
  • As a parameter within Input file, nope. – Brian Jan 30 '18 at 15:28
  • https://stackoverflow.com/questions/799250/i-o-redirection-in-eclipse – LMC Jan 30 '18 at 15:48
  • Those are outdated posts. Functionality was added in Eclipse Mars. – Brian Jan 30 '18 at 15:54
  • I don't think bash redirection will ever work since Eclipse is not using bash to run configurations. Wrap your command in a shell script an run it with `${resource_loc:/MyProject/input.txt} ${resource_loc:/MyProject/output.txt}` in the arguments. – LMC Jan 30 '18 at 17:22
  • I'm pretty sure you can. Otherwise, why would Eclipse implement the input and output file fields? – Brian Feb 01 '18 at 14:28
  • Agree, those fields are for a reason, what I meant is that `< >` redirectors are not usable as in a console or a bash script. I looked for variables that represent those fields and they are not defined in eclipse. – LMC Feb 01 '18 at 14:36
  • Oh yes, I definitely agree. I think the input and output fields is eclipse's way of getting around that. Unfortunately, I can't get those fields working, which is what my original question is about. – Brian Feb 02 '18 at 12:50
  • did you consider using a wrapper script? – LMC Feb 02 '18 at 13:12
  • Yes, but that's not what this question is asking. – Brian Feb 08 '18 at 18:32

0 Answers0