Previous Thread
Next Thread
Print Thread
Rate Thread
#104913 10/10/2003 12:16 PM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
Ok, the last one was too easy, so here's a deep one. smile

I'm writing a script for backing up files daily on my computer, which is running Win2000. The "backup" consists in copying a specified list of files to a separate directory (for subsequent manual transfer to a CD).

(I know there are existing backup utilities, but I don't know of one that provides the flexibility I need, and can obtain through writing my own script.)

1) My first attempt uses the Windows task scheduler to run a Perl script (via a .bat file) every two hours. The script uses a file to keep track of when the last backup was completed. Each time the script runs, it checks to see whether a backup was done within the last 24 hours. If so, the script simply exits. Otherwise it tells me it's time to do a backup, and asks me whether to proceed. If I say "yes", it does the backup and then reports that it's done, or displays any errors that occurred. If I say "no" (because I'm in the middle of doing something else with which the backup might interfere), the script exits.

This works fine, except for one annoying problem: Each time the script runs (every two hours), a command prompt window flashes up, even if the script doesn't produce output or request input.

Someone suggested setting up the scheduled task to run as a user other than the one who's logged on. That supposedly would prevent the command prompt window from appearing. I haven't actually tried this, but I suspect that the window would not be present even if the script needed to produce output or request input, so that wouldn't work.

2) My second approach was to write a Windows service, instead of using the task scheduler.

I found a cool Perl module Win32::Daemon that makes it relatively easy to write a service.

The first problem I ran into is how to interact with the service, since it needs to tell me when it's time to do a backup, and ask me for permission to proceed. I couldn't figuring out any way of getting a command prompt window to appear. Script input/output just seems to disappear into the bit bucket (that includes Perl compilation errors as well, but that's getting off track).

I'm currently attempting to use the Perl Tk module, included with the Perl distribution I have, to interact with the user. This sort of works, but it opens another can of worms, since now I have to deal with the Tk event loop, and probably using a secondary thread to do the backup itself, which can take several minutes, all inside a service.

Does anyone have any experience with this kind of stuff that might help? smile

Sponsored Links
Entire Thread
Subject Posted By Posted
Windows service using Perl Dave_L 10/10/2003 7:16 PM
Re: Windows service using Perl Charles Capps 10/10/2003 8:12 PM
Re: Windows service using Perl Burak 10/10/2003 10:04 PM
Re: Windows service using Perl Dave_L 10/11/2003 6:15 PM
Re: Windows service using Perl Dave_L 10/12/2003 9:01 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Zarzal
Zarzal
Berlin, Germany
Posts: 808
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)