 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
dc7669
Joined: 08 Oct 2008 Posts: 6
|
Posted: Mon Dec 22, 2008 10:22 pm Post subject: Using DOS command in CGI |
|
|
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. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue Dec 23, 2008 11:09 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
dc7669
Joined: 08 Oct 2008 Posts: 6
|
Posted: Tue Dec 23, 2008 10:41 pm Post subject: Window API |
|
|
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. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Dec 24, 2008 10:28 am Post subject: |
|
|
Code: | 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). |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Dec 24, 2008 4:45 pm Post subject: |
|
|
Code: | integer r,start_process@
r = start_process@('cmd /c copy "c:\techsupport\share1.f90" "c:\techsupport\ccpy.f90"', " ")
end |
Code: | 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 |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|