Silverfrost Forums

Welcome to our forums

Using DOS command in CGI

22 Dec 2008 9:22 #4129

I had a CGI that used Cissue to move/copy/del some files. It is now not working after IIS upgrade, server upgrade, etc. (It is somewhat related to my othe post a few months back.)

My code: Command='copy e:\rxemail\temp.htm e:\rxemail\temp2.htm' call cissue(Command, i) write(,) '<p>', Command, i

i=start_process@('copy e:\rxemail\temp.htm e:\rxemail\temp3.htm','') write(,) '<p> Start_Process@', i

Result will show up in Internet Explorer. The first i is 0, indicating the command good, but the sceond i is -1, indicating the command is bad. There is no copy.exe in the directory. Is that why the start_process@ command did not work?

Anyway, how can I use DOS command in CGI?

Thank you.

23 Dec 2008 10:09 #4131

There is a Windows API functin CopyFile that copies files directly, also the FTN95 routine ERASE@ can be used to delete a file.

To move a file you can copy then delete, then rename (RENAME@). A direct alternative is to use the Windows API MoveFileEx.

start_process@ and start_pprocess@ ought to work also.

23 Dec 2008 9:41 #4133

What is Window API? Can you give an example how CopyFile will work?

It seems to me that CGI and DOS Internal Commands (dir, del, copy, etc) don't work together any more. I tried using Cissue and Start_process@ using DOS Internal Commands and they all failed.

So, to copy a file, I resort to use open and write commands. For sure, if I don't know the length of each line, I am doomed. In my particular case, I know the length of each line in my file.

For delete a file, Erase@ works.

Thank you.

24 Dec 2008 9:28 #4134
      STDCALL MoveFile 'MoveFileA' (STRING,STRING):logical
      STDCALL CopyFile 'CopyFileA' (STRING,STRING,VAL):logical
      character*256 existingFile, newFile
      integer failIfExists
      logical done
      existingFile = 'c:\\techsupport\\share1.f90'
      newFile = 'c:\\techsupport\\copy.f90'
      failIfExists = 1
      done = CopyFile(existingFile, newFile, failIfExists)
      done = MoveFile(existingFile, newFile)
      end

You can use include <windows.ins> instead of the first two lines if you prefer.

The functions are described on the Microsoft MSDN website (use Google to locate).

24 Dec 2008 3:45 #4136
 integer r,start_process@
 r = start_process@('cmd /c copy 'c:\\techsupport\\share1.f90' 'c:\\techsupport\\ccpy.f90'', ' ')
 end


integer(2) ierr
call cissue@('copy 'c:\\techsupport\\share1.f90' 'c:\\techsupport\\ccpy.f90'', ierr)
end

For a DOS command, start_process@ requires the 'cmd /c' prefix. This is provided for you when you use cissue@. I have put the file name in double quotes but these are not required if the name does not contain spaces

Please login to reply.