473,385 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Unlink/rename works on linux, not working on windows??

Hi,

When I run my program on a linux machine it opens, renames, and unlinks the files as expected. However, when I run it on Windows it will not rename or unlink the files. Since it is opening and reading the files correctly, it seems that the problem is not in the difference between the path name styles.

Here are the relevant parts of the code:
Expand|Select|Wrap|Line Numbers
  1. open(INFILE, '<',  $the_infile) || die $!;  
  2. #read from infile, modify contents
  3.  
  4. open(OUTFILE, '>', $the_outfile) || die $!;
  5. #print modified contents to outfile
  6.  
  7. open(ORIG_INFILE, '>', $original_outfile) || die $!;
  8. #copy content from INFILE to ORIG_INFILE
  9.  
  10. unlink("$the_infile");
  11. #Rename the OUTFILE with the same name as the INFILE
  12. rename($the_outfile, $the_infile);
  13.  
  14. close (ORIG_INFILE);
  15. close (INFILE);
  16. close (OUTFILE);
  17.  
  18.  
I'm not sure if it's legal to rename($the_outfile, $the_infile) after I've unliked the $the_infile and I also wasn't sure if I had to close (INFILE) after I unlinked it. Even though it works fine on linux, could this possibly cause the problem on windows?

Any suggestions would be greatly appreciated!
Thanks!
Aug 11 '10 #1
2 4073
I solved the problem: Windows will not rename or delete files while they are open.
Aug 11 '10 #2
thanks for posting, this helped solve my problem. now i must repair the hole in the wall from where my head was banging against it.
Sep 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ronald Evers | last post by:
Hey all, I want to store passwords in a postgresql database. Currently I use the MD5Password class below and I've been developing on windows. I ran into problems when running my application on...
2
by: Tim Williams | last post by:
I'm using Python 2.3.2 and tkFileDialog in a program I have. I'm trying to use this on Linux (RH 8.0) and Windows 2000. When I first upgraded from v2.2 to v2.3. I noticed that...
1
by: corrado | last post by:
Hello I have an application running several thread to display some financial data; basically I have a thread displaying HTML tables by means of Tkhtml, another implementing a scrolling ticker...
1
by: ÖÜÕÑÌÎ | last post by:
hi,I want to get the names of the files in a directory on the linux and windows platform. I found that _findfirst(),_findnext() can work under windows but the code cann't work under linux ,if...
2
by: Andrej Litowka | last post by:
Hi All! If anybody know, how I cann set an enviroment variable (with ANSI C) on Windows similar like on Linux. I tried setenv, but the function doesn't work correct on Windows - it sets env....
6
by: jake | last post by:
How do you get or save a file from/to a client (button on web page) once they are authenticated? The client could be Mac, Linux or Windows. Can I do it all with IIS and ASP.NET?
5
by: Rothariger | last post by:
Hello.... i want to know if its posible to rename multiple files like windows does.. example: file zzzzzzz.doc file asdasd.doc file esfsefse.doc
8
by: nasse | last post by:
I am trying to rename a file in Windows XP server using the following php script but i am getting "Permission denied". <?php rename("file1.php", "file2.php"); ?> Pls help.
3
by: Blubaugh, David A. | last post by:
To All, I was wondering if it was possible to utilize python to share a memory resource between a linux and windows system?? It should be stated that both the Linux (CENTOS 5) and windows...
0
by: Blubaugh, David A. | last post by:
Diez, What you have said is extremely concerning. I am now using VMware. With Linux as the Master and windows as the guest operating system. I was wondering if you have ever had to develop...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.