×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

call system command

call system command

call system command

(OP)
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.

RE: call system command

Have you tried including the full path name (including drive label)?


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

RE: call system command

(OP)
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

 

RE: call system command

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)

RE: call system command

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')

RE: call system command

(OP)
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?

RE: call system command

(OP)
The code by xwb didnt work:

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

RE: call system command

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 ?

RE: call system command

(OP)
The command
program <IN.DAT
works at the command promt in a DOS window
 

RE: call system command

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')

RE: call system command

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.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources