>From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, December 13, 2005 2:58 PM
>To: Cutts III, James H.
>Cc: [email protected]
>Subject: Re: Setting File and Directory Group and Permissions via
Net::FTP
>
>Cutts III, James H. wrote:
>
>> I have an application using the Net::FTP module to move files from a
>> Windows system to a RH Linux box. The application copies the file
and
>> directory structure across the systems.
>>
>> The files that get transferred to the Linux box end up with the
>> permissions of "-rw-------" (600). I need the rights to be at least
>> "-rw-rw-r--" (664).
>>
>> The directories that get created have similarly restrictive
>> permissions of "drwx------" (700). I need the rights to be at least
"drwxr-xr-x"
>> (755).
>>
>> I can't seem find out how to change the permissions via the Net::FTP
>> module. I can do it manually from the command line via the chgmod
>> command but that defeats the purpose of automation.
>
>Have you tried using a 'site' command with args of 'chmod 664
filename.ext'
>
Thanks to all who've replied to my problem. I've semi and "sort of"
solved my immediate
problem by making a change to the FTP daemon on the Linux server
(fortunately, it's my
system to play with).
However, I've been unsuccessful in getting the suggestions of the ->quot
and ->site commands
to work. I've copied the relevant sections of the Perl code below as
well as the generated
output.
########################################################################
####
sub ftp_put_file #12/17/2005 6:22AM
########################################################################
####
{
my $source_file = $_[0];
my $dest_file = $_[1];
print "\nAttempting to ftp->put $source_file to $dest_file\n" if (
$debug_flag );
# FTP File to server
$rc = $ftp_session->put( $source_file, $dest_file );
$results = ftp_results( " ->put( $source_file, $dest_file )" );
print "$results\t\$rc=$rc\n" if ( $debug_flag );
# Change Directory Group to CORI <== per $Bill Luebker 2002-02-01
$rc = $ftp_session->quot( 'site', 'chgrp cori $dest_file' );
$results = ftp_results( "->quote( 'site', 'chgrp cori $dest_file' )
<== per \$Bill Luebker 2002-02-01" );
print "$results\t\$rc=$rc\n" if ( $debug_flag );
# Change Directory Group to CORI <== per my understanding of 'quot'
$rc = $ftp_session->quot( 'chgrp', "cori $dest_file" );
$results = ftp_results( "->quot( 'chgrp', \"cori $dest_file\" ) <==
per James H. Cutts III 2005-12-17" );
print "$results\t\$rc=$rc\n" if ( $debug_flag );
# Change Directory Group to CORI <== per $Bill Luebker 2005-12-13
$rc = $ftp_session->site( 'chgrp cori $dest_file' );
$results = ftp_results( "->site( 'chgrp cori $dest_file' ) <== per
\$Bill Luebker 2002-02-13" );
print "$results\t\$rc=$rc\n" if ( $debug_flag );
# Change Directory Group mode to rw
$rc = $ftp_session->quot( 'site', 'chmod 0755 $dest_file' );
$results = ftp_results( "->quote( 'site', 'chmod 0755 $dest_file' )"
);
print "$results\t\$rc=$rc\n\n" if ( $debug_flag );
} ## end of ##ftp_file
########################################################################
####
sub ftp_results #11/09/2004 11:16AM
########################################################################
####
{
my $label = $_[0];
my $message = $ftp_session->message();
my %ftp_code_text = (
110 => 'Restart marker reply',
120 => 'Service ready in nnn minutes',
<... Snip ...>
552 => 'Requested file action aborted, exceeded storage
allocation',
553 => 'Requested file action not taken, file name' ,
);
my $results = "ftp$label->message = '" . chomp( $message ) . "'\n\t";
$results .= "->code = (" . $ftp_session->code() . ") '" .
$ftp_code_text{$ftp_session->code()} . "'\n\t";
$results .= "->ok = '" . $ftp_session->ok() . "'\n";
return $results;
} ## end of ##ftp_results
Output results:
Attempting to ftp->put D:\Projects\CORI\Hardcopy\ftp_test.pl to
/home/cuttsj/play/ftp_test.pl
ftp ->put( D:\Projects\CORI\Hardcopy\ftp_test.pl,
/home/cuttsj/play/ftp_test.pl )->message = '1'
->code = (226) 'Closing data connection'
->ok = '1'
$rc=/home/cuttsj/play/ftp_test.pl
ftp->quote( 'site', 'chgrp cori /home/cuttsj/play/ftp_test.pl' ) <== per
$Bill Luebker 2002-02-01->message = '1'
->code = (500) 'Syntax error, command unrecognized'
->ok = ''
$rc=5
ftp->quot( 'chgrp', "cori /home/cuttsj/play/ftp_test.pl" ) <== per James
H. Cutts III 2005-12-17->message = '1'
->code = (500) 'Syntax error, command unrecognized'
->ok = ''
$rc=5
ftp->site( 'chgrp cori /home/cuttsj/play/ftp_test.pl' ) <== per $Bill
Luebker 2002-02-13->message = '1'
->code = (500) 'Syntax error, command unrecognized'
->ok = ''
$rc=5
ftp->quote( 'site', 'chmod 0755 /home/cuttsj/play/ftp_test.pl'
)->message = '1'
->code = (550) 'Requested action not taken; file unavailable
(e.g., file not found, no access)'
->ok = ''
$rc=5
As you see, I'm getting "Syntax error, command unrecognized" on the
chgrp command, and effectively
a "file not found" error on the "chmod" file. I'm beginning to wonder
if the problem may be with the
vsftpd FTP daemon I'm using on my RH Linux box. Does this FTP server
not support the chmod / chgrp
commands? If any one out there has experience with Linux FTP servers
and would like to comment on
this, I'd appreciate your input before I cross post this plea for help
to my Linux lists.
Thanks again.
James H. Cutts III
CORI - 143C Mumford
P.S. $Bill - I found a response from you in the archives from 2002 that
I have included in my test code.
P.S.S. (Way off topic) Does anyone know how to get Outlook to do a
decent job of creating nicely
formatted 80 character long message lines without it automatically
capitalizing the first word
after the carriage return and to use the ">" for the replied text?
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs