Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Of crontab and paths

by jimbus (Friar)
on Aug 18, 2005 at 18:34 UTC ( #484913=note: print w/ replies, xml ) Need Help??


in reply to Re: Of crontab and paths
in thread Of crontab and paths

I decided not to be as thorough as above, but that was good info for me to keep squirelled away. I did couple google searches and ran across Getopt and did the following:

use Utils; use Getopt::Long; my $conf_file = ''; GetOptions ('conf=s' => \$conf_file); if ( length($conf_file) == 0) { print "\nUsage: loadSMSC -conf=/path/to/config.properties\n"; exit; } %props = getProperties("$conf_file"); $node_name = $props{"node"}; $machine = $props{"machine"}; $username = $props{"username"}; $passwd = $props{"passwd"}; $directory = $props{"directory"}; $localpath = $props{"localpath"}; $log_name = $props{"log.name"}; $numRows = $props{"rows"};
getProperties is in Utils.pm and goes a little something like:
sub getProperties($) { my ($propfile) = @_; my (%props); # Return value: a hash of property values. my ($ln,$name,$value,@nv); open(PROPFILE,"$propfile") or die "Unable to open $propfile"; while ($ln = <PROPFILE>) { chomp $ln; $ln =~ s/#(.*$)//; # Remove line comments in the properties + file. @nv = split /s*=/,$ln,2; $value = pop @nv; $value =~ s/^\s*=?\s*//; $value =~ s/\s*$//; $name = pop @nv; $name =~ s/^\s*//; $name =~ s/\s*$//; if ($name ne "") { $props{$name} = $value; } } close(PROPFILE); return %props; } sub dumpProperties { my (%props) = @_; foreach $prop (keys %props) { #print "\t\t$prop\n"; print "\t\t$prop:$props{$prop}\n"; } 1; }
Thanks for the input!

Jimbus

A sniveling Jimbus advices, "Never moon a werewolf!"


Comment on Re^2: Of crontab and paths
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://484913]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2015-07-03 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls