1

I am using Net::SFTP::Foreign module to copy the files from remote to some source machine and after copy operation, able to retain the file creation time and permissions except the gid and uid.

After copy operation I have below attributes:

root@system # ls -n 

/dest/files -rw-r--r-- 1 0 0 4424 Jun 10 04:45 /dest/files/file.txt

While at source the attributes are:

root@source # ls -n 

/source/files -rw-r--r-- 1 1001 1002 4424 Jun 10 04:45 /source/files/file.txt

I used below code for SFTP operation:

my $sftp = Net::SFTP::Foreign->new(
    host      => $host
);
$sftp->get( $file, $dest, copy_perm => 1)

I have not found any option in documentation of Net::SFTP::Foreign for retaining the uid and gid.

Is anybody has any idea?

CodeQuestor
  • 881
  • 1
  • 11
  • 25
  • Looks like you might be able to use `$sftp->stat` and `$sftp->chown` and do it manually. – Jim Davis Aug 11 '15 at 07:30
  • $sftp->chown will modify the gid,uid of remote file not of local file.As after copying the file i want to retain the gid and uid, so i have to do this - chown $a->uid, $a>gid, $file; It is working for me. – CodeQuestor Aug 11 '15 at 07:32
  • Please post your solution as an answer and accept it. – simbabque Aug 11 '15 at 07:39

0 Answers0