Trying to check whether a file exists or not using the STATE command.
Have tried with
STATE filename STATE app\filename STATE app/filename STATE approot\app\filename STATE \\node\sharename\ibi\apps\directory\filename
All returns -1, despite the file actually exist.
We're on WF 5.2.7 on IBM iSeries (AS/400). Clue anyone?
Tia, Hakan
January 12, 2005, 03:36 PM
<Pietro De Santis>
Here's some code I found that works:
-SET &FDATE = AYMD(&YYMD,-1,'I8'); -SET &FN2 = '/ibi/srv51/ffs/catalog/sa'|EDIT(&FDATE,'$$999999')|'.ftm' ; STATE &FN2 -RUN -IF &RETCODE EQ 0 GOTO CREATED ;
November 06, 2006, 06:22 AM
hammo1j
Might be because your filename contains a blank or a dollar (don't know which).
Have to dos copy to a simple filename and then check that with STATE to get things to work.
Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2 Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
November 06, 2006, 11:19 AM
hammo1j
Tom
STATE does not work if there's a blank in the filename. Try this:
-DOS ECHO HELLO > "HELLO WORLD.TXT" -DOS TYPE "HELLO WORLD.TXT" DOS STATE "HELLO WORLD.TXT" -RUN -TYPE &RETCODE DOS DIR "HELLO WORLD.TXT" -EXIT
Regards
John
Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2 Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
November 06, 2006, 12:25 PM
hammo1j
Hakan
Another thing it might be is the Amper Autoprompter's annoying habit of removing backslashes from the code it passes onto the server. If you amper auto prompt you have to double up your backslashes because I think it gets treated as an escape character.
If anyone knows anything more about this and if it gets fixed in a later release, I would be interested to know.
Regards
John
Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2 Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
November 07, 2006, 11:48 AM
jbmuir
H. Lindholm,
I have experienced a non-functional STATE using FOCUS and unix. The alternative we used was to test the return code of the "ls" command. Hamm01j hinted at this solution, but to be explicit you may be able to deal with this annoying problem by doing something similar:
-DOS DIR "c:\path\to\my file.txt" -IF &RETCODE NE 0 THEN GOTO OOPS;
WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
November 07, 2006, 01:57 PM
hammo1j
jbmuir
Yes you guessed right the way round is to copy to a file without the space (which works) and then do the STATE on the target file that contains no spaces.
Here is a solution to check for file name containing spaces C:\HELLO WORLD.TXT. The solution is for windows servers only. I'm sure there are better solutions out there and would love to know of them, but this works ok.