You have to login in order to post a reply to this topic.

9 replies [Last post]
nambu
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 01/07/2010
Posts: 11

Hi, is it possible to change the working directory more than once during the same SFTP connection? I just want to make sure, as I'm getting an error.

 

What I'm doing is uploading files to websites in an Excel file:

 

1. Open SFTP Connection

2. Open Excel file with URLs

 

3. Start Loop (through all URLs in Excel file)

4. Read URL from LoopIndex row and store in %URL%

5. Change working directory in SFTP connection to folder %URL%

6. Upload files

7. End loop

 

8. Close Excel

9. Close SFTP Connection

 

The first time it loops, it changes the working directory fine, and uploads the files. But the second time, it always gives an error: "Cannot change working directory to...".

 

I know that the file paths are correct, because if I open and close the SFTP connection each time it loops, there is no error. For example, this loop works fine:

 

Start Loop (through all URLs in Excel file)

Open SFTP Connection

Read URL from LoopIndex row and store in %URL%

Change working directory in SFTP connection to folder %URL%

Upload files

Close SFTP Connection

End loop

 

So it seems that a new SFTP connection needs to be made each time I want to change the directory. Is this correct?

codex
codex's picture
User offline. Last seen 18 weeks 4 days ago. Offline
Joined: 11/12/2009
Posts: 161
Re: Change Working Directory twice during same SFTP connection?

Hello there! First, let me give you a direct answer: no, this is not correct: you do not have to create a new SFTP connection every time. Let me get in a little more detail about the "Change Working Directory" action:

When you use the specific action it always changes the directory relative to the directory that you are currently in. This is a pretty fundamental behavior of an FTP server and if the action was changing the directory based on the initial directory, it would cause even more confusion.

For example, if you had a folder structure like the following:

root dir
-- Sub Folder 1
-- Sub Folder 2
---- XSub Folder 1
------ EXSub Folder 1
------ EXSub Folder 2
---- XSub Folder 2

and you wanted to copy some files to "Sub Folder 2", "XSub Folder 1" and "EXSub Folder 2", all you have to do is the following:

Change Working Directory "Sub Folder 2"
Copy Files
Change Working Directory "XSub Folder 1"
Copy Files
Change Working Directory "EXSub Folder 2"
Copy Files

Below you can find an example:

Let's assume that you have a folder named "To Upload" that contains all the folders and files that you want to upload. In our example, it contains the following:

SubFolder1
SubFolder2
SubFolder3
File1
File2

Now, I'm guessing that your Excel file contains folders like the following:

site1
site2
site3

and you want to upload the files and folders in all these different folders.

However, here is the catch: the first time the job iterates, it changes the directory to "site1" and uploads the files and the folders. The second time, the active directory is site1 and the job tries to find a directory called site2 inside site1. If this is the case, the issue should be fixed by adding a "Change Working Directory" action just below the "Upload Folder to FTP" action (inside the loop) that will change the working directory to .. (2 periods). The 2 periods is a way to refer to the parent directory of the current one.

I hope that the description above helped you understand what is going on. Lemme know if you have any more questions!

__________________

Error is not blindness, error is cowardice

__________________

Error is not blindness, error is cowardice

nambu
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 01/07/2010
Posts: 11
Re: Change Working Directory twice during same SFTP connection?

Yes! That explained it perfectly. It's working fine now thanks to your help.

 

I love WinAutomation, and am glad to see that there is a forum open now. Thanks again codex!

codex
codex's picture
User offline. Last seen 18 weeks 4 days ago. Offline
Joined: 11/12/2009
Posts: 161
Re: Change Working Directory twice during same SFTP connection?

No problem m8! :-)

__________________

Error is not blindness, error is cowardice

__________________

Error is not blindness, error is cowardice

jobitt
jobitt's picture
User offline. Last seen 1 year 33 weeks ago. Offline
Joined: 06/09/2010
Posts: 7
Re: Change Working Directory twice during same SFTP connection?

Hi,

I have 2 hosting account, with hostacct1, the fix of changing directory to .. works but for my other hostaccount2, it is not working.

For hostacct2, requires FTPS explicit for secured ftp, it can establish connection ok but only having problems in changing directory. hostacct1 uses normal open ftp.

Would this be hosting side issue?

Any help would be greatly appreciated.

D.M.Altizer
User offline. Last seen 1 year 11 weeks ago. Offline
Joined: 01/12/2010
Posts: 204
Re: Change Working Directory twice during same SFTP connection?

 Hmm... This is not something common. Actually it is the first time that I hear about such a problem... Do you get a specific error message when you are trying to change the directory? Can you upload to or download from the FTP server? Or is it just the changing of the directory that does not work?
 

__________________

==Dedicated Automation Solutions==

__________________

==Dedicated Automation Solutions==

jobitt
jobitt's picture
User offline. Last seen 1 year 33 weeks ago. Offline
Joined: 06/09/2010
Posts: 7
Re: Change Working Directory twice during same SFTP connection?

Looks like there is a problem in upload (I have big file and usually takes more time with a working job-using hostacct1) .

Winauto is showing where you're at in your action, and this one is only on first record  , change dir to url provided, upload, then change working dir to ..

The upload action was very quick, then the change working dir to .. give error message  "Error in action 11: Cannot change working directory to .. "

For ftp action for the job,  I use open secure ftp connection and ftps explicit protocol.

Manual upload, I use filezilla and I have attached here my settings. No problem using filezilla with upload/download.

 

 

 

AttachmentSize
filezilla.jpg 16.62 KB
D.M.Altizer
User offline. Last seen 1 year 11 weeks ago. Offline
Joined: 01/12/2010
Posts: 204
Re: Change Working Directory twice during same SFTP connection?

 Which version of WinAutomation are you using? I am under the impression that there are some changes in v3.1 related to the SFTP connection creation action. If you have a virtual machine where you can test the new version (it is still on beta stage) you can send an email at the support department of WinAutomation and ask to be added in the beta testing group. If the new version does not solve the problem, we can explore some other options.

__________________

==Dedicated Automation Solutions==

__________________

==Dedicated Automation Solutions==

jobitt
jobitt's picture
User offline. Last seen 1 year 33 weeks ago. Offline
Joined: 06/09/2010
Posts: 7
Re: Change Working Directory twice during same SFTP connection?

Just bought it about a week ago and ver is 3.0.3.410 edition prof. I don't have a virtual machine so I will just wait for the release. Any guesstimate when it will be?

D.M.Altizer
User offline. Last seen 1 year 11 weeks ago. Offline
Joined: 01/12/2010
Posts: 204
Re: Change Working Directory twice during same SFTP connection?

My advice? Drop an email at support@winautomation.com and ask them.
 

__________________

==Dedicated Automation Solutions==

__________________

==Dedicated Automation Solutions==