cd in script returns 'no such file' error

Advertisement

nitram
Joined:
Posts:
7

cd in script returns 'no such file' error

I am running WinSCP 4.1.7 on WinXP SP3, running a script in console mode, passing 3 parameters. The parameters are for session name, a filename, and a remote directory name. The script tries to 'cd' to the remotedirectory. I get 'no such file' error. This is because WinSCP is appends parameter %3% to the default folder path. However, the directory I want to change to is not a subfolder of the default directory.

Default session directory is: /afs/myserver/home/c/m/cmartin
I want to change to this folder: /afs/myserver/depts/med/cgibd/public_html/POPS/Asher

WinSCP attempts cd as: '/afs/myserver/home/c/m/cmartin/%3%' instead of '%3%'

Here is cmdline:
----------------
"C:\Program Files\WinSCP\WinSCP.com" /log="E:\Docs\Batch\Libs\winscp.log" /script="E:\Docs\Batch\Libs\put.txt" /parameter myserv_cfm "E:\Docs\Batch\Libs\RefFile.txt" /afs/myserver/depts/med/cgibd/public_html/POPS/Asher

Here is the script:
------------------
option batch on
option confirm off
option transfer automatic
open %1%
cd %3%
close
exit

Here is the log:
---------------
. 2010-06-16 16:10:47.731 --------------------------------------------------------------------------
. 2010-06-16 16:10:47.731 Using SFTP protocol.
. 2010-06-16 16:10:47.762 Doing startup conversation with host.
> 2010-06-16 16:10:47.762 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2010-06-16 16:10:47.762 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2010-06-16 16:10:47.762 SFTP version 3 negotiated.
. 2010-06-16 16:10:47.762 We believe the server has signed timestamps bug
. 2010-06-16 16:10:47.762 We will use UTF-8 strings for status messages only
. 2010-06-16 16:10:47.762 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2010-06-16 16:10:47.762 Changing directory to "/afs/myserver/home/c/m/cmartin".
. 2010-06-16 16:10:47.762 Getting real path for '/afs/myserver/home/c/m/cmartin'
> 2010-06-16 16:10:47.762 Type: SSH_FXP_REALPATH, Size: 43, Number: 16
< 2010-06-16 16:10:47.762 Type: SSH_FXP_NAME, Size: 89, Number: 16
. 2010-06-16 16:10:47.762 Real path is '/afs/myserver/home/c/m/cmartin'
. 2010-06-16 16:10:47.762 Trying to open directory "/afs/myserver/home/c/m/cmartin".
> 2010-06-16 16:10:47.762 Type: SSH_FXP_LSTAT, Size: 43, Number: 263
< 2010-06-16 16:10:47.762 Type: SSH_FXP_ATTRS, Size: 37, Number: 263
. 2010-06-16 16:10:47.762 Getting current directory name.
. 2010-06-16 16:10:47.762 Startup conversation with host finished.
. 2010-06-16 16:10:47.778 Changing directory to "%3%".
. 2010-06-16 16:10:47.778 Getting real path for '/afs/myserver/home/c/m/cmartin/%3%'
> 2010-06-16 16:10:47.778 Type: SSH_FXP_REALPATH, Size: 47, Number: 528
< 2010-06-16 16:10:47.778 Type: SSH_FXP_STATUS, Size: 29, Number: 528
< 2010-06-16 16:10:47.778 Status/error code: 2, Message: 528, Server: No such file, Language:
* 2010-06-16 16:10:47.778 (ECommand) Error changing directory to '%3%'.
* 2010-06-16 16:10:47.778 Cannot get real path for '/afs/myserver/home/c/m/cmartin/%3%'.
* 2010-06-16 16:10:47.778 No such file or directory.
* 2010-06-16 16:10:47.778 Error code: 2
* 2010-06-16 16:10:47.778 Error message from server: No such file
* 2010-06-16 16:10:47.778 Request code: 16
. 2010-06-16 16:10:47.794 Closing connection.
. 2010-06-16 16:10:47.794 Sending special code: 12
. 2010-06-16 16:10:47.794 Sent EOF message

This is log from a GUI session, just to show that remote directory exists:
--------------------------------------------------------------------------
Cached directory change via "/afs/myserver/depts/med/cgibd/public_html/POPS/Asher" to "/afs/myserver/depts/med/cgibd/public_html/POPS/Asher".
Getting current directory name.
Listing directory "/afs/myserver/depts/med/cgibd/public_html/POPS/Asher".
Type: SSH_FXP_OPENDIR, Size: 65, Number: 16907
Type: SSH_FXP_STATUS, Size: 24, Number: 16644
Discarding reserved response
Type: SSH_FXP_HANDLE, Size: 13, Number: 16907
Type: SSH_FXP_READDIR, Size: 13, Number: 17164
Type: SSH_FXP_NAME, Size: 879, Number: 17164
Type: SSH_FXP_READDIR, Size: 13, Number: 17420
Type: SSH_FXP_STATUS, Size: 28, Number: 17420
Status/error code: 1
Type: SSH_FXP_CLOSE, Size: 13, Number: 17668

Reply with quote

Advertisement

nitram
Joined:
Posts:
7

Re: cd in script returns 'no such file' error

If I hard code the remote direc, it works. This batch works without error:

option batch on
option confirm off
option transfer automatic
open %1%
cd /afs/myserver/depts/med/cgibd/public_html/POPS/Asher
close
exit

But when I pass the remote directory as a paramter to the script, (as shown in orig post), it fails because WinSCP appends the parameter value to existing folder rather than using it as is.

Shouldn't it be possible to pass a remote direc as a parameter?

Chris





nitram wrote:

I am running WinSCP 4.1.7 on WinXP SP3, running a script in console mode, passing 3 parameters. The parameters are for session name, a filename, and a remote directory name. The script tries to 'cd' to the remotedirectory. I get 'no such file' error. This is because WinSCP is appends parameter %3% to the default folder path. However, the directory I want to change to is not a subfolder of the default directory.

Default session directory is: /afs/myserver/home/c/m/cmartin
I want to change to this folder: /afs/myserver/depts/med/cgibd/public_html/POPS/Asher

WinSCP attempts cd as: '/afs/myserver/home/c/m/cmartin/%3%' instead of '%3%'

Here is cmdline:
----------------
"C:\Program Files\WinSCP\WinSCP.com" /log="E:\Docs\Batch\Libs\winscp.log" /script="E:\Docs\Batch\Libs\put.txt" /parameter myserv_cfm "E:\Docs\Batch\Libs\RefFile.txt" /afs/myserver/depts/med/cgibd/public_html/POPS/Asher

Here is the script:
------------------
option batch on
option confirm off
option transfer automatic
open %1%
cd %3%
close
exit

Here is the log:
---------------
. 2010-06-16 16:10:47.731 --------------------------------------------------------------------------
. 2010-06-16 16:10:47.731 Using SFTP protocol.
. 2010-06-16 16:10:47.762 Doing startup conversation with host.
> 2010-06-16 16:10:47.762 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2010-06-16 16:10:47.762 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2010-06-16 16:10:47.762 SFTP version 3 negotiated.
. 2010-06-16 16:10:47.762 We believe the server has signed timestamps bug
. 2010-06-16 16:10:47.762 We will use UTF-8 strings for status messages only
. 2010-06-16 16:10:47.762 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2010-06-16 16:10:47.762 Changing directory to "/afs/myserver/home/c/m/cmartin".
. 2010-06-16 16:10:47.762 Getting real path for '/afs/myserver/home/c/m/cmartin'
> 2010-06-16 16:10:47.762 Type: SSH_FXP_REALPATH, Size: 43, Number: 16
< 2010-06-16 16:10:47.762 Type: SSH_FXP_NAME, Size: 89, Number: 16
. 2010-06-16 16:10:47.762 Real path is '/afs/myserver/home/c/m/cmartin'
. 2010-06-16 16:10:47.762 Trying to open directory "/afs/myserver/home/c/m/cmartin".
> 2010-06-16 16:10:47.762 Type: SSH_FXP_LSTAT, Size: 43, Number: 263
< 2010-06-16 16:10:47.762 Type: SSH_FXP_ATTRS, Size: 37, Number: 263
. 2010-06-16 16:10:47.762 Getting current directory name.
. 2010-06-16 16:10:47.762 Startup conversation with host finished.
. 2010-06-16 16:10:47.778 Changing directory to "%3%".
. 2010-06-16 16:10:47.778 Getting real path for '/afs/myserver/home/c/m/cmartin/%3%'
> 2010-06-16 16:10:47.778 Type: SSH_FXP_REALPATH, Size: 47, Number: 528
< 2010-06-16 16:10:47.778 Type: SSH_FXP_STATUS, Size: 29, Number: 528
< 2010-06-16 16:10:47.778 Status/error code: 2, Message: 528, Server: No such file, Language:
* 2010-06-16 16:10:47.778 (ECommand) Error changing directory to '%3%'.
* 2010-06-16 16:10:47.778 Cannot get real path for '/afs/myserver/home/c/m/cmartin/%3%'.
* 2010-06-16 16:10:47.778 No such file or directory.
* 2010-06-16 16:10:47.778 Error code: 2
* 2010-06-16 16:10:47.778 Error message from server: No such file
* 2010-06-16 16:10:47.778 Request code: 16
. 2010-06-16 16:10:47.794 Closing connection.
. 2010-06-16 16:10:47.794 Sending special code: 12
. 2010-06-16 16:10:47.794 Sent EOF message

This is log from a GUI session, just to show that remote directory exists:
--------------------------------------------------------------------------
Cached directory change via "/afs/myserver/depts/med/cgibd/public_html/POPS/Asher" to "/afs/myserver/depts/med/cgibd/public_html/POPS/Asher".
Getting current directory name.
Listing directory "/afs/myserver/depts/med/cgibd/public_html/POPS/Asher".
Type: SSH_FXP_OPENDIR, Size: 65, Number: 16907
Type: SSH_FXP_STATUS, Size: 24, Number: 16644
Discarding reserved response
Type: SSH_FXP_HANDLE, Size: 13, Number: 16907
Type: SSH_FXP_READDIR, Size: 13, Number: 17164
Type: SSH_FXP_NAME, Size: 879, Number: 17164
Type: SSH_FXP_READDIR, Size: 13, Number: 17420
Type: SSH_FXP_STATUS, Size: 28, Number: 17420
Status/error code: 1
Type: SSH_FXP_CLOSE, Size: 13, Number: 17668

Reply with quote

Advertisement

You can post new topics in this forum