im trying to copy a directory on a remote machine. basically just renaming it on the remote machine. for some reason it will not let me do this saying that the "cp" is missing the destination file. my code follows...
# Creates path to home directory $homedir = "/var/www/localhost/htdocs/$user_name"; # Sets user directroy path $last_user_dir = "/var/www/localhost/htdocs/$last_user_name"; # Start of ssh my $ssh_conn=Net::SSH::Perl->new( $ssh_host, debug => 3, protocol => +'2'); $ssh_conn->login( $ssh_user, $ssh_pass ); ($stdout, $stderr, $exit) = $ssh_conn->cmd( "cp -r $last_user_dir $hom +edir"); $ssh_conn->cmd( "rm -r $last_user_dir" ); $ssh_conn->cmd( "exit" );
debug output
dns1: Reading configuration data /root/.ssh/config dns1: Reading configuration data /etc/ssh_config dns1: Allocated local port 1023. dns1: Connecting to primerib.otelco.net, port 22. dns1: Remote protocol version 2.0, remote software version OpenSSH_4.2 dns1: Net::SSH::Perl Version 1.29, protocol version 2.0. dns1: No compat match: OpenSSH_4.2. dns1: Connection established. dns1: Sent key-exchange init (KEXINIT), wait response. dns1: Algorithms, c->s: 3des-cbc hmac-sha1 none dns1: Algorithms, s->c: 3des-cbc hmac-sha1 none dns1: Entering Diffie-Hellman Group 1 key exchange. dns1: Sent DH public key, waiting for reply. dns1: Received host key, type 'ssh-dss'. dns1: Host 'primerib.otelco.net' is known and matches the host key. dns1: Computing shared secret key. dns1: Verifying server signature. dns1: Waiting for NEWKEYS message. dns1: Enabling incoming encryption/MAC/compression. dns1: Send NEWKEYS, enable outgoing encryption/MAC/compression. dns1: Sending request for user-authentication service. dns1: Service accepted: ssh-userauth. dns1: Trying empty user-authentication request. dns1: Authentication methods that can continue: publickey,password,key +board-interactive. dns1: Next method to try is publickey. dns1: Trying pubkey authentication with key file '/root/.ssh/id_dsa' dns1: Authentication methods that can continue: publickey,password,key +board-interactive. dns1: Next method to try is publickey. dns1: Next method to try is password. dns1: Trying password authentication. dns1: Login completed, opening dummy shell channel. dns1: channel 0: new [client-session] dns1: Requesting channel_open for channel 0. dns1: channel 0: open confirm rwindow 0 rmax 32768 dns1: Got channel open confirmation, requesting shell. dns1: Requesting service shell on channel 0. dns1: channel 1: new [client-session] dns1: Requesting channel_open for channel 1. dns1: Entering interactive session. dns1: Sending command: cp -r /var/www/localhost/htdocs/bnorthct /var/www/localhost/htdocs/test dns1: Requesting service exec on channel 1. dns1: channel 1: open confirm rwindow 0 rmax 32768 dns1: channel 1: rcvd eof dns1: channel 1: output open -> drain dns1: input_channel_request: rtype exit-status reply 0 dns1: channel 1: rcvd close dns1: channel 1: input open -> closed dns1: channel 1: close_read dns1: channel 1: obuf empty dns1: channel 1: output drain -> closed dns1: channel 1: close_write dns1: channel 1: send close dns1: channel 1: full closed dns1: channel 2: new [client-session] dns1: Requesting channel_open for channel 2. dns1: Entering interactive session. dns1: Sending command: rm -r /var/www/localhost/htdocs/bnorthct dns1: Requesting service exec on channel 2. dns1: channel 2: open confirm rwindow 0 rmax 32768 dns1: channel 2: rcvd eof dns1: channel 2: output open -> drain dns1: input_channel_request: rtype exit-status reply 0 dns1: channel 2: rcvd close dns1: channel 2: input open -> closed dns1: channel 2: close_read dns1: channel 2: obuf empty dns1: channel 2: output drain -> closed dns1: channel 2: close_write dns1: channel 2: send close dns1: channel 2: full closed dns1: channel 3: new [client-session] dns1: Requesting channel_open for channel 3. dns1: Entering interactive session. dns1: Sending command: exit dns1: Requesting service exec on channel 3. dns1: channel 3: open confirm rwindow 0 rmax 32768 dns1: channel 3: rcvd eof dns1: channel 3: output open -> drain dns1: input_channel_request: rtype exit-status reply 0 dns1: channel 3: rcvd close dns1: channel 3: input open -> closed dns1: channel 3: close_read dns1: channel 3: obuf empty dns1: channel 3: output drain -> closed dns1: channel 3: close_write dns1: channel 3: send close dns1: channel 3: full closed cp: missing destination file Try `cp --help' for more information. bash: line 1: /var/www/localhost/htdocs/test: No such file or director +y
i can provide more if needed. thank you for any help or pointing in the right direction.

Edited by planetscape - added readmore tags

( keep:0 edit:14 reap:0 )


In reply to Net::SSH::Perl remote copying issues by rbnorthcutt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.