jsz wrote:
Then it's definitely not a bash(1) issue but a C++ one.
I think your wrong.
The OP actually asked :
Quote:
The program saves files in its own directory. How can I tell it to save all output files in an existing subdirectory "data"? Or even better, check the existence of a subdirectory "data", create "data" if it does not exist, and tell the program to save there.
It seems like your telling him it can't be done... it can.
# If a sub directory named "data" doesn't exist, if it doesn't create it
Code:
if [ ! -d "data" ]; then
mkdir data
fi
# Tell the program to save there ...
Method one
# The simplest method would be to move (mv) them
after they are created
# Say they all had the extention .final ...then
Code:
(echo $p; echo 10; echo 10; echo 2000; echo 1000) | ./finalsim
mv *.final data/
Method two
# How about you just cd to data and THEN run the program
# Notice the TWO dots in front of your command, as it's in the dir above
Code:
cd data/
(echo $p; echo 10; echo 10; echo 2000; echo 1000) | ../finalsim
Maybe not extremely pretty, perhaps not perfect.....but it works.
The only thing that you may have to take into account with the second method, is if your "finalism" program is getting data from the original directory

Hope that helps.