Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: [SPARK] Shtorm on September 25, 2007, 10:35:24 am
-
Hello! Can anybody explain result of this function? I write this function to show this very strange result.
procedure test_shell_ex();
var i: integer;
begin
writeln('[SPARK] Shtorm: It is very strange, but it is fact...');
for i:=1 to 10 do writelnfile ('testfile.txt', IntToStr(i)+' .... string'); // write to file
shell_exec('cmd /c del /F /Q testfile.txt'); // delete file, it's file are DELETED!!!
try
writeln(readfile('testfile.txt')); // read deleted file
except
writeln('none'); // If file not exists - write 'none'
end;
writeln('End of function'); // bye
end;
Then i see...
[SPARK] Shtorm: It is very strange, but it is fact...
1 .... string
2 .... string
3 .... string
4 .... string
5 .... string
6 .... string
7 .... string
8 .... string
9 .... string
10 .... string
[SPARK] Shtorm: End of function
To get result of this function use command line "soldatserver.exe -safe 0", to work shell_exec.
Why this function read deleted file??? :o :o :o This file can is not removed yet!!! But why???? >:(
ps: server run on WinXP.
-
It's what's known as a race condition; you can't guarantee the order that things will be executed because shell exec is (eventually) an asynchronous call.
Essentially, the script finishes running before the shell command starts.
-
And cmd.exe is already called in shell exec.
-
How can i use function, if i don't know time of perfomance???
I think, that there is a requirement to rewrite function shell_exec that it waited the ending of work shell.
And cmd.exe is already called in shell exec.
But don't work. Call "shell_exec('cmd /c del /F /Q testfile.txt');" without "cmd /c" have not any result. You may check this.