RE: How to chdir using SFTP or SSH on Win32



Hi Rob,

Yeah, I got all that but unfortunately I need a workaround due to a coding
error on the server end. The server-end SFTP logic is a rewrite of an
earlier FTP app that still expects a CD before the GET. Any ideas? Magic?

Thanks,
Sturdy


-----Original Message-----
From: Rob Dixon [mailto:rob.dixon@xxxxxxx]
Sent: Wednesday, May 21, 2008 12:15 PM
To: beginners@xxxxxxxx
Cc: Sturdevant, Robert W Mr CTR USA AMC
Subject: Re: How to chdir using SFTP or SSH on Win32

Sturdevant, Robert W Mr CTR USA AMC wrote:
Hi list,

I asked this question a few days ago on the perl-win32-users list but
still need some help. It seems what I need may not be possible.

I have a perl (5.6) SFTP client (Net::SFTP) that gets and puts files
using either a full or relative path with the filename something like
this:

$sftp->get( $remotename, $localname ); # where $remotename =
'/Home/OUT/myfile.txt'

But I have a remote system with a custom server app that rejects the
path and requires a chdir to the correct file location. To fetch a
file I need to do something like this:

$sftp->chdir( $path ); #cd to the OUT folder
$sftp->get( $shortname, $localname); # get the file using only the
file name

I see no way to do $sftp->chdir. Please advise if something similar is
possible. I have tried many combinations of commands using SSH such as
$ssh->cmd( 'cd $path' ) with no joy. $ssh->cmd() always seems to hang.
TIA.

SSH doesn't support a cwd command - it is the job of the client to keep
track of where it is in the remote directory structure. You can establish
the path to your login directory by executing

$sftp->do_realpath('.');

and after that you can specify either a path relative to that login
directory or an absolute path. The location of '.' never changes.

HTH,

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx For additional
commands, e-mail: beginners-help@xxxxxxxx http://learn.perl.org/


Attachment: smime.p7s
Description: S/MIME cryptographic signature



Relevant Pages

  • Re: how to connect to a remote machine using python........
    ... Some python ssh packages are available if you are wanting to execute ... commands on a machine that has ssh. ... you could run a Python-based web server from a simple ...
    (comp.lang.python)
  • Re: Good sftp server?
    ... >SSH for OpenVMS is capable of doing text transfers. ... >colon on them unless you are using our SFTP client... ... version of the server (and is something I complained about to Multinet ... files between MacOS X and VMS, and use a directory structure on the Mac ...
    (comp.os.vms)
  • Re: FTPS Server for OpenVMS (Also posted to the ITRC)
    ... what is an FTPS server? ... Do you mean SFTP (Secure ... SSH, SFTP, etc are available as part of TCP/IP Services for OpenVMS. ...
    (comp.os.vms)
  • Re: free/cheap Windows SSH client that supports login scripts?
    ... connect, the commands will run. ... to a given server running SSH and then log straight into the mysql ... SecureCRT is so much nicer than anything else out there, ... cheap if you are a heavy ssh user. ...
    (comp.security.ssh)
  • Re: how to supply sftp with password?
    ... bash-3.00$ sftp user@server ... SFTP added server to the list of known ... provide an SSH key, unlock it for your application, and limit its power on the ... Can you install the '.ssh/authorized_keys' file on the target server? ...
    (comp.security.ssh)