The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
.
google unix.com



Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Number of open files (Dir's) how to close? satyam90 UNIX for Advanced & Expert Users 1 11-07-2008 09:17 AM
close open files before remove xramm SUN Solaris 9 09-14-2007 08:23 AM
Close Socket at HP-UX Renato Gregio HP-UX 2 08-14-2007 10:04 AM
Should a UNIX daemon process close open fds? kunalashar UNIX for Dummies Questions & Answers 1 10-24-2002 09:10 AM
File status - open/close ?? Pal UNIX for Dummies Questions & Answers 3 09-26-2001 03:54 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-31-2008
quattro20v's Avatar
quattro20v quattro20v is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 3
Can DOS close an open file?

I'm trying to setup a cron job for my brother that goes out to the web and retrieves an excel file and overwrites the existing copy on his desktop. The problem I'm facing is I have to kill the process (excel.exe) if the file is open while the batch file runs, otherwise, it will create another copy with a 1 or 2 or 3, etc appended to the end of the filename. For example, the correct filename would be myfile.xls and it will create myfile.xls(1). So, I kill the process before it goes out to the web to retrieve the file. This works, but ideally, I would like to close that particular file without killing the process in the event he has other files in open state . . . is this possible?
  #2 (permalink)  
Old 12-31-2008
reborg's Avatar
reborg reborg is online now Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,208
Not easily and not directly through DOS. You would have to write a control for excel to close and reopen the file.
  #3 (permalink)  
Old 01-01-2009
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
You might try the following:

The cron job first retrieves the file and saves it locally under a unique name. Then it runs a loop which terminates as soon as the excel.exe process goes away and then moves the file to the final destination. In pseudocode:

Code:
get_file_from_internet()
save_file( "some_unique_name" )
while ( excel.exe is running ) {
     wait()
}

move_file( "some_unique_name", "myfile.xls" )
end()
Depending on the frequency of how often the cron job runs and how often it gets a new version of the file you might have to implement some sort of locking mechanism because a cron job could already be waiting to replace the file when the next one starts and retrieves an even newer version of the file.

I hope this helps.

bakunin
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0