Rename command in NT

When I want to use a NT server, can I the use the rename command???
This command workes fine in UNIX.
mmcwAsked:
Who is Participating?
 
Kim RyanConnect With a Mentor IT ConsultantCommented:
Does this help you ?

use Win32::File;
use English;

if $::OSNAME eq 'MSWin32'
{
  Win32::File::SetAttributes     ("ordersnew.txt ", NORMAL) or die $!;
}
else ( chmod(...) }
0
 
ozoCommented:
Is it not working for you in NT?  What do you get in $! when it fails?
0
 
mmcwAuthor Commented:
I have a script made for unix but someone has now a problem using this script. I get an error on this line where I use the command rename. Thats why I thought that NT did not understand the command rename.

rename "$order_dir/ordersnew.txt","$order_dir/$order_database" or print "can't rename ordersnew.txt,$order_database:$!";

I get the error:
can't rename ordersnew.txt,orders.txt:Permission denied.

This is automaticaly made by a little error routine. It says that th file orderneew.txt can not be renamed to order.txt!

Do you understand why the script produces this error on a NT machine.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Kim RyanIT ConsultantCommented:
rename should work for NT exactly the same as Unix, but you must have permission to rename the file. Try renaming the file through DOS command line or Windows Explorer to check if you do. If the file properties are set to hidden or read-only, you should change them.
0
 
mmcwAuthor Commented:
I have set them to chmod 666. Is that OK.
0
 
Kim RyanIT ConsultantCommented:
chmod only has meaning in Unix. If you right click on a file from Window explorer, you can see its properties. The Read-Only or Hidden attributes should not be set.
0
 
mmcwAuthor Commented:
In the script I use I set the right of the file ordersnew.txt to chmod 666.
This workes fine for UNIX. Does this mean that it does not work for NT. If so how to set the right in NT
0
 
mmcwAuthor Commented:
Addition to question:

How to set the right in the script.
In the script for unix I use:

chmod(0666,$datadirSub);

Does this work for NT
0
 
Kim RyanIT ConsultantCommented:
As I mentioned chmod won't actually do anything to your NT files, even though it won't return error. Try this module

use Win32::File;
use English;

if $::OSNAME eq 'MSWin32' {
Win32::File::SetAttributes   ("ordersnew.txt ", $attrib | NORMAL) or die $!;
}
else ( chmod(...) }
0
All Courses

From novice to tech pro — start learning today.