Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call system command

Status
Not open for further replies.

TheKKK

Mechanical
Mar 22, 2009
21
0
0
GR
i would like to run an program.exe through my fortran code in a folder different than my fortran code

I have used the following 3 codes but the system cannot find the file specified:

1.
call system ('folder\program <IN.DAT')

2.
call system ('\folder\program <IN.DAT')

3.
call system ('cd folder')
call system ('program <IN.DAT')

Could anyone help me? Thanx in advance.
 
Replies continue below

Recommended for you

It doesnt work also when entering the full path like this:

call system ('C:\Users\kostis\Documents\COMPUTATIONAL PHYSICS 4th\PROJECT SCREEN3\screen3LOOP\folder\program <IN.DAT')

however i can create a file in the folder like this:

OPEN(UNIT=99,FILE='folder\IN.DAT',STATUS='REPLACE')

so i would expect this:

call system ('folder\program <IN.DAT')

to work

 
Does

folder\program <IN.DAT

work successfully at the command prompt in a DOS window?


In the full path name instead of using the long name version with spaces try the equivalent short name version (8.3 format)
 
Like everything else, Sysyem does not like spaces in file or directory names. Try
Code:
call system ('"C:\Users\kostis\Documents\COMPUTATIONAL PHYSICS 4th\PROJECT SCREEN3\screen3LOOP\folder\program.exe" <IN.DAT')
 
The
folder\program <IN.DAT
doesnt work in a DOS window so i shouldnt expect it to work throygh my code.

But then the
call system ('cd folder')
call system ('program <IN.DAT')
should work then but it doesnt also

How can i put these two commands in a single line?
 
The code by xwb didnt work:

call system ('"C:\Users\kostis\Documents\COMPUTATIONAL PHYSICS 4th\PROJECT SCREEN3\screen3LOOP\folder\program.exe" <IN.DAT')
 
does

program <IN.DAT

work at the command prompt in a DOS window?


Programs I write that pick up data file names from the launching command line don't require the < symbol , I use the standard fortran "call get_command_argument" to do this (without a <)


What error message did you get in the DOS window with folder\program <IN.DAT ?
 
Code:
call system ('cd folder')
call system ('program <IN.DAT')
This won't work because it spawns two separate shells; the first cds to a directory and then exits, the second attempts to execute and then exits. To put both commands on the same line, join them with &&
Code:
call system ('cd folder && program < in.dat')
 
It has been a long time since I did any FORTRAN, but at the back of my head there is a tiny recollection that with one of the compilers I used you had to use two backslashes ("\\") if you wanted to feed SYSTEM a string that was intended to contain a single backslash ("\").

HTH.
 
Status
Not open for further replies.
Back
Top