|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I wanted to set permissions for files as they are created, so I'm using the chmod function. I couldn't get it to work so I set up a "test" and still nothing.
$file_name = $co->param('file_name'); $permission = $co->param('permission'); if ($file_name) { $success = chmod $permission, '$file_name'; if ($success == 0) { $message = "<font face=arial color=red>Unable to set permissions for file $file_name to $permission.</font>"; } } Any ideas? |
|
#2
|
||||
|
||||
|
You made need to use back ticks to execute the system call to chmod:
Code:
$success = `chmod $permission, $file_name`; And only use one comma, between the chmod $permission and the file_name. Besure your chmod setting is in the UNIX format, IE: 0644 Mickalo
__________________
Thunder Rain Internet Publishing Custom Programming & Database development Providing Personal/Business Internet Solutions that work! |
|
#3
|
|||
|
|||
|
Thanks,
I tried the back ticks...chmod still returns zero. I'm only using one comma and have the extra zero for octals. Any other ideas??? |
|
#4
|
||||
|
||||
|
Is this on a UN*X box or NT??
|
|
#5
|
|||
|
|||
|
Unix (remote-SSL Host)
|
|
#6
|
||||
|
||||
|
Quote:
Ok, I see what it is your trying to do. The $success variable is assigned a value but your not doing anthing with it, so it will always return "0". Try this: Code:
$file_name = $co->param('file_name');
$permission = $co->param('permission');
$success = undef;
if ($file_name) {
chmod $permission, "$file_name" and $success = 1;
if ($success != 1) {
$message = "<font face=arial color=red>Unable to set permissions for file $file_name to $permission.</font>";
}
}
Now the $success variable has been assigned a value and the value is checked, and if the chmod is successfully it is set to "1" otherwise it's undefined. Mickalo |
|
#7
|
|||
|
|||
|
Thanks,
It works. The octals were being read as decimals so I added the oct. chmod oct $permission, "$file_name" and $success = 1; I originally did this $success = chmod $permissions...... because I thought chmod returns the number of files it affects. Again, Thanks |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > chmod func. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|