Testing for remote directory existence before copying files

Advertisement

will.waterston@gmail.com
Joined:
Posts:
4
Location:
Brisbane, Australia

Testing for remote directory existence before copying files

I'm using Session.FileExists(mypath) to test if a directory exists, but without success.

Is this method meant for testing path existence or only files?

I've tried FileExists("/myroot/mypath/") both with and without the trailing / and both are returning false even though the directory does exist. If this method is only meant for files then how do I test directory existence?

I found some more notes in the forum on this and FileExists() is supposed to support directories as well as files. Below is log for the events surrounding the failure. The script failure explains why the method is returning false, but what can I do stop the script failing on the unexpected directory listing?

Looking further this appears to be related to an unexpected directory listing format. I have seen several comments suggesting to change the ls command using sed to modify the format, but I cannot see where this is done using .NET assembly, can someone point me in the direction of the doco for this?

Thanks
 2023-02-02 14:41:30.621 Enumerating network events for socket 1064
. 2023-02-02 14:41:30.621 Enumerated 1 network events making 1 cumulative events for socket 1064
. 2023-02-02 14:41:30.621 Handling network read event on socket 1064 with error 0
. 2023-02-02 14:41:30.621 Waiting for another 1 bytes
. 2023-02-02 14:41:30.621 Looking for incoming data
. 2023-02-02 14:41:30.621 Looking for network events
. 2023-02-02 14:41:30.621 Received 32 bytes
. 2023-02-02 14:41:30.621 Timeout waiting for network events
. 2023-02-02 14:41:30.621 Read 1 bytes (31 pending)
. 2023-02-02 14:41:30.621 Read 1 bytes (30 pending)
< 2023-02-02 14:41:30.621 /
. 2023-02-02 14:41:30.621 Read 30 bytes (0 pending)
< 2023-02-02 14:41:30.621 WinSCP: this is end-of-file:0
. 2023-02-02 14:41:30.621 Startup conversation with host finished.
< 2023-02-02 14:41:30.621 Script: Session started.
< 2023-02-02 14:41:30.621 Script: Active session: [1] root@10.8.92.78
. 2023-02-02 14:41:30.621 Session upkeep
. 2023-02-02 14:41:30.621 Looking for network events
. 2023-02-02 14:41:30.621 Timeout waiting for network events
> 2023-02-02 14:41:30.704 Script: pwd
< 2023-02-02 14:41:30.704 Script: /
. 2023-02-02 14:41:30.704 Session upkeep
. 2023-02-02 14:41:30.704 Looking for network events
. 2023-02-02 14:41:30.704 Timeout waiting for network events
> 2023-02-02 14:41:30.711 Script: pwd
< 2023-02-02 14:41:30.711 Script: /
. 2023-02-02 14:41:30.711 Session upkeep
. 2023-02-02 14:41:30.711 Looking for network events
. 2023-02-02 14:41:30.711 Timeout waiting for network events
> 2023-02-02 14:41:30.756 Script: stat -- "/www"
> 2023-02-02 14:41:30.756 Script: Parameter: /www
. 2023-02-02 14:41:30.756 Listing file "/www".
> 2023-02-02 14:41:30.756 ls -la -d  "/www" ; echo "WinSCP: this is end-of-file:$?"
. 2023-02-02 14:41:30.756 Sent 58 bytes
. 2023-02-02 14:41:30.756 There are 0 bytes remaining in the send buffer
. 2023-02-02 14:41:30.756 Looking for network events
. 2023-02-02 14:41:30.756 Timeout waiting for network events
. 2023-02-02 14:41:30.756 Waiting for another 1 bytes
. 2023-02-02 14:41:30.756 Looking for incoming data
. 2023-02-02 14:41:30.756 Looking for network events
> 2023-02-02 14:41:30.761 Script: stat -- "/www"
> 2023-02-02 14:41:30.761 Script: Parameter: /www
. 2023-02-02 14:41:30.761 Listing file "/www".
> 2023-02-02 14:41:30.761 ls -la -d  "/www" ; echo "WinSCP: this is end-of-file:$?"
. 2023-02-02 14:41:30.761 Sent 58 bytes
. 2023-02-02 14:41:30.761 There are 0 bytes remaining in the send buffer
. 2023-02-02 14:41:30.761 Looking for network events
. 2023-02-02 14:41:30.761 Timeout waiting for network events
. 2023-02-02 14:41:30.761 Waiting for another 1 bytes
. 2023-02-02 14:41:30.761 Looking for incoming data
. 2023-02-02 14:41:30.761 Looking for network events
. 2023-02-02 14:41:30.894 Detected network event
. 2023-02-02 14:41:30.894 Enumerating network events for socket 1056
. 2023-02-02 14:41:30.894 Enumerated 1 network events making 1 cumulative events for socket 1056
. 2023-02-02 14:41:30.894 Handling network read event on socket 1056 with error 0
. 2023-02-02 14:41:30.894 Waiting for another 1 bytes
. 2023-02-02 14:41:30.894 Looking for incoming data
. 2023-02-02 14:41:30.894 Looking for network events
. 2023-02-02 14:41:30.894 Received 44 bytes
. 2023-02-02 14:41:30.894 Received 30 bytes
. 2023-02-02 14:41:30.894 Timeout waiting for network events
. 2023-02-02 14:41:30.894 Read 1 bytes (73 pending)
. 2023-02-02 14:41:30.894 Read 43 bytes (30 pending)
< 2023-02-02 14:41:30.894 drwxr-xr-x   11         0 Feb  2 15:32 /www
. 2023-02-02 14:41:30.894 Read 30 bytes (0 pending)
< 2023-02-02 14:41:30.894 WinSCP: this is end-of-file:0
< 2023-02-02 14:41:30.896 Script: Can't get attributes of file '/www'.
< 2023-02-02 14:41:30.896 Unexpected directory listing line 'drwxr-xr-x   11         0 Feb  2 15:32 /www'.
. 2023-02-02 14:41:30.896 Script: Failed
. 2023-02-02 14:41:30.896 Session upkeep
. 2023-02-02 14:41:30.897 Looking for network events
. 2023-02-02 14:41:30.897 Timeout waiting for network events
. 2023-02-02 14:41:30.901 Detected network event
. 2023-02-02 14:41:30.901 Enumerating network events for socket 1064
. 2023-02-02 14:41:30.901 Enumerated 1 network events making 1 cumulative events for socket 1064
. 2023-02-02 14:41:30.901 Handling network read event on socket 1064 with error 0
. 2023-02-02 14:41:30.901 Waiting for another 1 bytes
. 2023-02-02 14:41:30.901 Looking for incoming data
. 2023-02-02 14:41:30.901 Looking for network events
. 2023-02-02 14:41:30.901 Received 44 bytes
. 2023-02-02 14:41:30.901 Timeout waiting for network events
. 2023-02-02 14:41:30.901 Read 1 bytes (43 pending)
. 2023-02-02 14:41:30.901 Read 43 bytes (0 pending)
< 2023-02-02 14:41:30.901 drwxr-xr-x   11         0 Feb  2 15:32 /www
. 2023-02-02 14:41:30.901 Waiting for another 1 bytes
. 2023-02-02 14:41:30.901 Looking for incoming data
. 2023-02-02 14:41:30.901 Looking for network events
. 2023-02-02 14:41:30.903 Detected network event
. 2023-02-02 14:41:30.903 Enumerating network events for socket 1064
. 2023-02-02 14:41:30.903 Enumerated 1 network events making 1 cumulative events for socket 1064
. 2023-02-02 14:41:30.903 Handling network read event on socket 1064 with error 0
. 2023-02-02 14:41:30.903 Waiting for another 1 bytes
. 2023-02-02 14:41:30.903 Looking for incoming data
. 2023-02-02 14:41:30.903 Looking for network events
. 2023-02-02 14:41:30.903 Received 30 bytes
. 2023-02-02 14:41:30.903 Timeout waiting for network events
. 2023-02-02 14:41:30.903 Read 1 bytes (29 pending)
. 2023-02-02 14:41:30.903 Read 29 bytes (0 pending)
< 2023-02-02 14:41:30.903 WinSCP: this is end-of-file:0
< 2023-02-02 14:41:30.903 Script: Can't get attributes of file '/www'.
< 2023-02-02 14:41:30.903 Unexpected directory listing line 'drwxr-xr-x   11         0 Feb  2 15:32 /www'.
. 2023-02-02 14:41:30.903 Script: Failed
. 2023-02-02 14:41:30.903 Session upkeep

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum