Forum Moderators: coopster & phranque

Message Too Old, No Replies

calling config file from argument

         

wizpl

4:22 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



I need to edit the following part of code to set configuration file based on an argument.
In the script I have tried to define a variable

$newsfeed = $ARGV

and a path to config file as:

my $cfgFile = "/hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/config/$newsfeed";

then I wanted to run the whole script from html:
http://www.example.com/cgi-bin/pullrss/pullrss.cgi?soundtrack.cfg
where "soundtrack.cfg" would be a name of a config file.

well, all this did not work. What have I done wrong?

the original code was:

use strict;
use HTTP::Request;
use LWP::UserAgent;
use XML::Parser;
use XML::RSS;
use HTML::Template;
use URI::URL ();

# Variables defined in external file
use vars qw($externalRSS
$localRSS
@siteDomains
$hTemplate
$outfile
$siteId
$ADMIN_EMAIL
$numheadlines
$redirectServer);

# Retrieve configuration file/parameters
my $cfgFile = "/hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cfg";
$cfgFile = $ARGV[0] if ($ARGV[0]);

die "Specified Config file ($cfgFile) doesn't exist.\n" unless (-e $cfgFile);
require $cfgFile or die "Can't retrieve configuration file: $!\n";

# Agent name for external file pulls
my $AGENT_NAME="pullrss/1.0";

# grab and format headlines from the RSS file
my $topHeadlines = &pullRSS($externalRSS,$localRSS,$numheadlines,\@siteDomains,$hTemplate);

[1][edited by: jatar_k at 1:22 am (utc) on Sep. 17, 2005]

wizpl

4:34 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



and I'm getting this errors running it by cron job:

Global symbol "$newsfeed" requires explicit package name at /hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cgi line 48.
syntax error at /hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cgi line 49, near "my "
Global symbol "$cfgFile" requires explicit package name at /hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cgi line 49.
Global symbol "$newsfeed" requires explicit package name at /hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cgi line 49.
Global symbol "$cfgFile" requires explicit package name at /hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cgi line 53.

[edited by: coopster at 11:01 pm (utc) on Sep. 16, 2005]
[edit reason] generalized url [/edit]

KevinADC

5:18 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



this error:

syntax error at /hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/pullrss.cgi line 49, near "my "

needs to be fixed first. Try and determine what the syntax error is (missing quotes, missing semi-colon, etc etc etc). If you can't figure it out, post the code if it's not too long and someone will take a look.

[edited by: coopster at 11:02 pm (utc) on Sep. 16, 2005]
[edit reason] generalized url from original poster [/edit]

Moby_Dim

5:24 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



Do this:

my $cfgFile = '/hsphere/local/home/abelkorz/example.com/cgi-bin/pullrss/'.$ARGV[0];

and remove your url and site name (read TOS ;) And own security is not a penny cost too ;)

And all the messages means the script is running 'use strict' Specify all variables as private (my) or strict pragma should be disabled.

[edited by: coopster at 11:02 pm (utc) on Sep. 16, 2005]
[edit reason] generalized url from original poster [/edit]

wizpl

10:15 pm on Sep 16, 2005 (gmt 0)

10+ Year Member



Thank you Moby_Dim, it did the trick. I had only to # the next line of code: $cfgFile = $ARGV[0] if ($ARGV[0]);

BTW removing my URLs, how can I edit my posts on this forum, can't find it... how nube am I...

jatar_k

1:13 am on Sep 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



it's ok, you can't edit after a while, we don't mind getting them but we do appreciate remembering for next time ;)

when you can edit, there is a small icon under your username that says 'owner edit'