There are several ways that you can
create a simple one line text file on a remote (or local) machine using
STAF/STAX. Here are a couple of suggestions:
1) You can use the STAF ECHO service's
ECHO request and redirect the output to a file to create a simple one line
text file on a remote (or local) machine.
For example, via STAF:
STAF client1 ECHO ECHO Here is some
data > C:/temp/myfile.txt
For example, via a STAX job, use a <process>
element to submit a STAF ECHO request and redirect standard output to a
file:
<script>
machine = 'client1'
textFile = 'C:/temp/myfile.txt'
data = 'Here is some data'
</script>
<process name="'Create text
file'">
<location>machine</location>
<command mode="'shell'">'STAF
local ECHO ECHO %s' % (data)</command>
<stdout>textFile</stdout>
</process>
<if expr="RC != 0">
<log message="1">
'Error writing text
to file %s on machine %s, RC=%s Result=%s' % \
(textFile, machine,
RC, STAFResult)
</log>
</if>
2) Or, you can use Jython code to create
a text file on the local STAX machine. If you want it on a remote
machine, then you can use the FS COPY request to copy the file to the remote
machine. For example:
<script>
# Create a temporary file
on the local STAX system
toMachine = 'client1'
textFileName = 'C:/temp/myfile3.txt'
localTextFileName = 'C:/temp/myfile.txt'
data = 'Here is some data'
<!-- Copy file to a remote machine
-->
<stafcmd name="'Copy text
file'">
<location>'local'</location>
<service>'FS'</service>
<request>
'COPY FILE %s TOFILE
%s TOMACHINE %s TEXT' % \
(localTextFileName,
textFileName, toMachine)
</request>
</stafcmd>
<if expr="RC != 0">
<log message="1">
'Error copy text file
%s to file %s on machine %s, RC=%s Result=%s' % \
(localTextFileName,
textFileName, toMachine, RC, STAFResult)
</log>
</if>
<!-- Delete the temporary file
on the local STAX system -->
<script>
import os
os.remove(localTextFileName)
</script>
--------------------------------------------------------------
Sharon Lucas
IBM Austin, lucass@us.ibm.com
(512) 838-8347 or Tieline 678-8347
"Tim Broad" <Tim.Broad@notesdev.ibm.com> Sent by: staf-users-admin@lists.sourceforge.net
03/23/2006 01:22 PM
To
staf-users@lists.sourceforge.net
cc
Subject
[staf-users] The FS Service
does not have a Create file method
I just want to create simple one line text files. Is there a way in
staf/stax without having to create a script for the purpose?
Thanks, Tim
978 399 6012
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users