Hi,

You can do this very easily (and simply) with the FS service.  The FS LIST
DIRECTORY request has a TYPE option.  If you specify TYPE D, it will only
list the directories; if you specify TYPE F, it will only list the files.

Here is a sample STAX job:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">

<stax>

  <defaultcall function = "Main"/>

  <script>
    remoteMachine = 'remote-machine'
    remotePath = 'C:/Windows/system32'
  </script>

  <function name = "Main">

    <sequence>

      <!-- List the directories on the remote machine and iterate
           through the directories -->
      <stafcmd>
        <location>remoteMachine</location>
        <service>'FS'</service>
        <request>'LIST DIRECTORY %s TYPE D' % (remotePath) </request>
      </stafcmd>

      <iterate in="STAFResult" indexvar="index" var="currentDirectory">
        <log>'Directory %s: %s' % (index + 1, currentDirectory)</log>
      </iterate>

      <!-- List the files on the remote machine and iterate
           through the files -->
      <stafcmd>
        <location>remoteMachine</location>
        <service>'FS'</service>
        <request>'LIST DIRECTORY %s TYPE F' % (remotePath) </request>
      </stafcmd>

      <iterate in="STAFResult" indexvar="index" var="currentFile">
        <log>'File %s: %s' % (index + 1, currentFile)</log>
      </iterate>

    </sequence>

 </function>

</stax>

Notice that you can use an <iterate> to iterate through each returned
file/directory.

Regarding your other question about returning both the list of files and
the list of directories in the remote STAX job, you can use:

<return>dirList, fileList</return>

Note, however, that in your main job, the object that gets returned from
the remote STAX job is just going to be one long string, so you will have
to have code in your main job to manually parse through the string to
access the individual files/directories.

So, again, I recommend the approach shown in the above STAX job.

Thanks,
David


                                                                       
 David Bender          11501 Burnet Rd.   Phone (T/L): 1-512-286-5315  
 STAF/STAX Development Bldg. 903-5B002    (363-5315)                   
                       Austin, TX         ITN: 23635315                
 IBM Software Group,   78758-3400         Email: bda...@us.ibm.com     
 WPLC                                                                  
                                                                       
                                                                       






                                                                       
  From:       Sunny A <sunn...@tcs.com>                                
                                                                       
  To:         David Bender/Austin/i...@ibmus                            
                                                                       
  Cc:         staf-users@lists.sourceforge.net                         
                                                                       
  Date:       06/02/2010 05:09 AM                                      
                                                                       
  Subject:    Re: [staf-users] Query regarding directory/file('s) display       
and     transfer
                                                                       






Hi ,
Sorry for cluttering your mailbox.

My main requirement is that suppose we have a main directory MAIN and it
contains 200 subdirectories and some files.

Now we want to get the list of 200 directories in one list and the files in
second list (Right now we are not considering the files in the
sub-directories.)

We don't want to use FS service because it will give a separate list of
everything and when we do FS COPY DIRECTORY,it will copy all files serially
by directory after directory which consumes time.

Bcoz of the following drawback,we want separate list for files and
directories so that we can just parallel iterate and use FS COPY FILE and
FS COPY DIRECTORY.

Hope u got me :)

Let me know your inputs if any.



Thanks and Regards,
Sunny Arora


                                                                       
 From:    David Bender <bda...@us.ibm.com>                             
                                                                       
 To:      Sunny A <sunn...@tcs.com>                                    
                                                                       
 Cc:      staf-users@lists.sourceforge.net                             
                                                                       
 Date:    06/02/2010 03:48 AM                                          
                                                                       
 Subject: Re: [staf-users] Query regarding directory/file('s) display and
          transfer                                                     
                                                                       






To access just the result part, you can do:

<log message="1">STAFResult['result']</log>

An alternative to submitting a remote STAX EXECUTE request, you could just
use a <process> in your local STAX job, to run an "ls" (on Unix) or
"dir" (on Windows) on the remote system to get the directory content. You
could also use <process> to run a "cp" (on Unix) or "copy" (on Windows),
but of course those commands could not copy the files to remote machines.

I still don't understand why you don't want to use a <stafcmd> to submit
the remote FS LIST/COPY requests. Using the FS service provides a common
command to do the list/copy regardless of the operating system, which means
you will have simpler code (especially since you won't have to parse the
output from the OS command, since the directory listing from the FS LIST
request will be marshalled data).

Regarding having 2 lists (one for files and one for directories), note that
if you use a FS COPY DIRECTORY request with the RECURSE option, it will
copy all of the files and directories (including subdirectories).

Can you elaborate on why you don't want to use a <stafcmd> to submit the
remote FS requests?

Thanks,
David


                                                                       
 David Bender          11501 Burnet Rd.   Phone (T/L): 1-512-286-5315  
 STAF/STAX Development Bldg. 903-5B002    (363-5315)                   
                       Austin, TX         ITN: 23635315                
 IBM Software Group,   78758-3400         Email: bda...@us.ibm.com     
 WPLC                                                                  
                                                                       






Inactive hide details for Sunny A ---06/01/2010 01:44:02 PM---My files are:
Test.xml(On remote machine)Sunny A ---06/01/2010 01:44:02 PM---My files
are: Test.xml(On remote machine)
                                                                       
                                                                       
 From:     Sunny A <sunn...@tcs.com>                                   
                                                                       
                                                                       
 To:       staf-users@lists.sourceforge.net                            
                                                                       
                                                                       
 Date:     06/01/2010 01:44 PM                                         
                                                                       
                                                                       
 Subject:  [staf-users] Query regarding directory/file('s) display and 
           transfer                                                    
                                                                       





My files are:
Test.xml(On remote machine)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">


<stax>


<defaultcall function = "Main"/>


<function name = "Main">


<function-list-args>
<function-arg-def name="path" type="required"/>
</function-list-args>


<sequence>


<script>
import os
dirlist = os.listdir(path)
</script>


<return>dirlist</return>


</sequence>


</function>


</stax>


Mian.xml(on local machine):


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">


<stax>


<defaultcall function = "Main"/>


<script>
remoteJob = 'C:/tests/listDir.xml'
remoteMachine = 'staf3a'
remotePath = '\'C:/tests\''
</script>


<function name = "Main">


<sequence>


<stafcmd>
<location>remoteMachine</location>
<service>'STAX'</service>
<request>'EXECUTE FILE %s MACHINE %s ARGS %s WAIT RETURNRESULT' %
(remoteJob, remoteMachine, remotePath) </request>
</stafcmd>


<log message="1">STAFMarshalling.formatObject(STAFResult)</log>


</sequence>


</function>


</stax>


Then when you submit the local job, the log would have the following (i.e.
the dir listing from the remote machine in the "result"):


20100525-15:40:38 {
result : ['cvsbackup.xml', 'listDir.xml', 'Scenario1.xml', 'stress.xml']
endTimestamp : 20100525-15:39:17
status : Normal
staf-map-class-name: STAF/Service/STAX/JobResult
testcaseTotals : {}
startTimestamp : 20100525-15:39:17
jobID : 21
}


Hi All,


Can u please answer my query.


>From the above mentioned o/p by running the script , i only need the result
part.
Also i need to have two lists,one for files and other for directories so
that when i am transferring,
These two lists will be returned so that the files present in the fileList
are transferred using FS copy file and directories in the dirList can be
transferred using FS Copy Dir.


Is there anyway to do this.
Also is there any way to do it without using STAX/FS service.
Do let me know your inputs.




Thanks,
Sunny


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you

------------------------------------------------------------------------------


_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------


_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you

------------------------------------------------------------------------------


_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users





<<inline: graycol.gif>>

<<inline: ecblank.gif>>

------------------------------------------------------------------------------

_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to