Don't ask to ask, just ask | |
PerlMonks |
Remove Script for a Infrastructure file managenet system running embedded perlby sanju7 (Acolyte) |
on Jul 18, 2010 at 00:07 UTC ( [id://850123]=perlquestion: print w/replies, xml ) | Need Help?? |
sanju7 has asked for the wisdom of the Perl Monks concerning the following question: About the environment : The script stays on central location but runs through an agent on remote hosts . Central server pushes the script to a scheduler on remote machines to a version of embedded perl similar to standard perl version 5.8.8 . I wrote my script on simple concept, given a path, it walks down the directory tree from a given path ( Path could be local path like "c:\windows", "/usr/local" or shared path "\\serverhost\share" since agents on windows or linux or mac could run it) , check if any of the directories has any file present or not, then delete those directories if there is no file on them. My script only partially successful, fails on shared server paths. Here my script part of an automation server / client program runs on remote agents (on windows , linux or mac clients) after following, <1> Files have been copied from source ($ThisSourceDirectory ) to destination location <2> Archive(for added security ) of the above files after the copy job from source ($ThisSourceDirectory ) to archive location($ThisMoveTarget) completes. <3> If archive is ok then cleanup script checks certain condition and upon satisfying removes the empty directory structure from source location. My Script
Short explanation My script checks few condition: (I) Checks if previous task was ok by Error=0 etc (II) checks if the veriabls such as "sourceDir" , "DestinationDir" are defined etc and Yes/ No string (III) walks down the directory tree, checks if files present at each location of given directory tree . (IV) delete all directories which doesnt have any files present on them. The script is tested with perl on Linux and Windows and it works from central server on agents with the embedded perl as well. However i need following help. My Issue with this code: It runs and removes files from windows, Linux (not tested with Mac yet --i.e not as important now)local directories however it doesn't work on shared storage path such as "\\hostname\directory\sub".The above script when run on the embedded perl on a central server works fine but silently quits when it gets "\\servername\share" type path. It should ideally (I) check the source location ( mostly a uri like"\\Sharedhost\directory\source\") (II) walks the directories down the source "\\Sharedhost\directory\source\ ... \ ... \" etc (problem) I am not getting how to tell the script to check the ($ThisSourceDirectory) variable and depending what is there (windows style local or shared storage location or mounted directory etc like "c:\dir" or /root/dir" etc --do it straightway and if necessary (i.e "\\servername\dir" type locations) recreate the variable to differentiate hostname from share dir etc and then, (a) connect the server share (b)do the check and run cleanup if matches criteria (c)then exit if ok etc About my script: Since its an embedded version of perl its not readily accepting external modules so i refrained from using them (however all suggestions are welcome). Making it work with shared path is an issue. Not getting how to achieve or if it need module or a c routine perhaps to do the network call to remote share host etc. If you can pinpoint and help me construct a better way, have an idea with a code snippet that you think may work would be a grateful . Thanks again for reading this far.
Back to
Seekers of Perl Wisdom
|
|