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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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
Kim RyanIT 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.