in reply to Re^3: rput on foreign sftp in perl
in thread rput on foreign sftp in perl

Thank you for the reply and for your the suggestions on the names, the doc does refer to using the umask parameters for controlling permissions, but in researching the umask command I saw the following: - The umask command cannot grant extra permissions beyond what is specified by the program that creates the file or directory. If you need to make permission changes to existing file use the chmod command. - some of the files I am dealing with are replacement files and using umask does not allow it to be changed to 0777(the best I can get to is 0755). I am trying to use the sftp 'chmod' command but not getting good results, I am supplying the 'chmod' command the full path on the linux server, but it is coming back saying the file does not exist, although I think that is a generic error supplied to state it was not successful (Couldn't setstat remote file (chmod): No such file) . The second topic of the file arriving with a 0 length, I did see a post http://www.tek-tips.com/viewthread.cfm?qid=1674115 that if a file is owned by someone other than me but they are in the same group (ie. I can read/write to the file), this will cause the put (rput) command to not be allowed to change the permissions on the file, thus getting the 0 length file. I followed the suggestions on the post (in below command line in the code), but I am still receiving the 0 length. Also changed the Unix.pm file to have a buffer value of 4096 and still getting zero length files.

$sftp->rput($source_ftp_dir, $destination_ftp_dir, copy_perm => 0, cop +y_time => 0) $sftp->chmod($full_path_dest_file, 0777) or die "count not chmod file +\n" . $sftp->error;

Replies are listed 'Best First'.
Re^5: rput on foreign sftp in perl
by kcott (Archbishop) on Sep 18, 2013 at 05:10 UTC

    Firstly, I'm not convinced that $source_ftp_file is, in fact, a directory. Everything in your code suggests otherwise:

    ... foreach my $file (@files) { my $source_ftp_file = $inputDir . "/". $file; ... # put file to server $sftp->rput($source_ftp_file, ... ... }

    I suggest you use the file test operators to check this.

    If they are files, use put() with an absolute value for the perm option. If you can't change the permissions of an existing file, perhaps you can delete it first. If you can't do either of those, perhaps there's a reason that you'll need to discuss with a system administrator.

    If they are directories, and you can't satisfactorily transfer them with a single rput(), perhaps you'll need to walk the directory structure and transfer them individually with put() as described in the preceding paragraph.

    -- Ken