Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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/\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{""}; $numRows = $props{"rows"};
getProperties is in 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!


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://484913]
[Happy-the-monk]: NodeReaper: that would have to go uphill.
[Happy-the-monk]: LanX&Corion: renting a car might be an option... ~150 but we need to travel early on Tuesday.
[LanX]: early on tuesday (morning)? why?
[LanX]: trains are probably not that bad...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2018-03-19 12:48 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.