SFTP create file list from current directory

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
5 posts Page 1 of 1

RodEgan

Posts: 3
Joined: Fri Sep 12, 2014 1:38 am

Post by RodEgan » Fri Oct 03, 2014 1:35 am
Can I get a file list from an SFTP resource using 'Ceate File List ' that starts at the current directory rather than at the root directory?
ie. folder structure
/root/folder/file

SFTP connect
create file list
->fileset
(entry in file list '/root/folder/file')

cd /root
create file list
->fileset
(entry in file list 'folder/file')
What I get is /root/folder/file

All that the 'base directory' parameter in file set appears to do is act as a mask to only provide a file list with entries from the matching folder BUT the file list still includes the 'base directory'.
I know I could manipulate the path but I expected either the current directory to be the base for a create file list.
What's the secret?

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Oct 07, 2014 3:35 pm
RodEgan,

The value returned is a FileList of the Physical Location of the file for the UserID connected to that server. The Relative Location is not returned (ie, based on current location in the folder path)

Your option here is to manipulate the FileList variable Path if you need to do that.

What is your business need here? Why would you need something Other than the Full access path to the File?

Maybe there is something else we can help you define that would meet your Business Need... Please advise!
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

RodEgan

Posts: 3
Joined: Fri Sep 12, 2014 1:38 am

Post by RodEgan » Tue Oct 07, 2014 6:55 pm
Business case is copying a folder structure via SFTP to a different file system. Either local network or another SFTP destination.
ie
source:
/root/folder1/folder2.1/files
/root/folder1/folder2.2/other files

workspace:
/workspace root/folder2.1/files
/workspace root/folder2.2/other files

destination:
(new root)
/new root/folder2.1/files
/new root/folder2.2/files

I know I could write code to manipulate the path. I was expecting to avoid doing that by changing directory to the relevant level on the respective file systems and then creating the fileset.
It wasn't clear in the documentation that it worked like a pseudo mask, It wasn't what I expected.
I can understand why it was done, it's not what I require for my application.
If the only way to obtain a fileset from the current directory is to manipulate the path string then that's what we'll work with.

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Fri Oct 24, 2014 11:39 am
I'm perplexed by this situation.

If you create a FileList a variable. (Using Task createfileList)
Then, include the recursive value. (All sub-folders included)

This will generate a FileList of all files within those folders and transfer them via SFTP to the Target server, creating the folder structure just as you have it on the Source server.

The key here is making sure there is at least 1 file in each folder you need to replicate across systems. The CreateFileList does not just replicate a skeleton File Structure with no files.

In this instance, the business model you indicate above should work as needed:

For example:

Code: Select all
<module name="Main">

	<createFileList label="Get files to Transfer" fileListVariable="Files" version="1.0">
		<fileset dir="C:\Temp\Demos" recursive="true" />
	</createFileList>

	<sftp label="Connect to Target" resourceId="Ricks Laptop sFTP" version="1.0">
		<put label="Push to Target" sourceFilesVariable="${Files}" destinationDir="/inbound/" />
	</sftp>

</module>
This will get all files and sub-files under the C:\Temp\Demos folder and SFTP that same file structure to the /inbound/ folder on the Target Server. Creating the file structure as it transfers. But, ignoring any folders that do not have files.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

RodEgan

Posts: 3
Joined: Fri Sep 12, 2014 1:38 am

Post by RodEgan » Sun Oct 26, 2014 6:43 pm
The key points here are
via SFTP
and that changing the directory via a CD command doesn't alter the base directory for the fileset.
All that the 'base directory' parameter in file set appears to do is act as a mask to only provide a file list with entries from the matching folder BUT the file list still includes the 'base directory'.
The fileset function base directory appears to allways uses the SFTP logon root as it's base directory, it doesn't appear to use the current directory on the SFTP server.
If my observations are correct than it may help future users if the documentation reflects that when using SFTP that the fileset base directory uses the SFTP login root directory as it's base and not the current directory.

Try creating a fileset on an SFTP server with a filestructure similar to below.
With a base directory or /root/folder1/

/root/folder1/folder2.1/files
/root/folder1/folder2.2/other files

Then:
cd /root/folder1/
and create another file set with a base directory of /

I was expecting to see a difference in path in the filesets.
It depends upon your definition of 'base directory', I expected it to be equivalent to the current directory and for the path saved to exclude the base directory component in a fileset.
It is a semantic point now as we have moved forward since we raised the issue several weks ago.
5 posts Page 1 of 1