Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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]
NodeReaper sorts his collection of toe tags, by blood type

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-03-29 17:20 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (352 votes). Check out past polls.