No Print output

W

William

my objective is to get the "desk" using the CGI script accmgr.

in display.pl:

61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
62 print $desk;

in accmgr:
71 elsif ($ACTION eq "getDesk") {
72 $STATUS_MSG=getDesk();
73 }

553 # get the desk from user.cfg and return this desk to display.pl to
show/hide radio buttons
554 sub getDesk{
555 return $USERS{$Group};
556 }



my question: why is there no print outout on line 62 of display.pl?
i.e. print $desk;
 
G

Gunnar Hjalmarsson

William said:
my objective is to get the "desk" using the CGI script accmgr.

in display.pl:

61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
62 print $desk;

in accmgr:
71 elsif ($ACTION eq "getDesk") {
72 $STATUS_MSG=getDesk();
73 }

553 # get the desk from user.cfg and return this desk to display.pl to
show/hide radio buttons
554 sub getDesk{
555 return $USERS{$Group};
556 }



my question: why is there no print outout on line 62 of display.pl?
i.e. print $desk;

Because of the error on line 139.

http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
S

Sherm Pendley

William said:
my objective is to get the "desk" using the CGI script accmgr.

Never heard of it.
in display.pl:

61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
62 print $desk;
Okay.

in accmgr:
71 elsif ($ACTION eq "getDesk") {
72 $STATUS_MSG=getDesk();
73 }

How is that related to what's in display.pl?
553 # get the desk from user.cfg and return this desk to display.pl to
show/hide radio buttons
554 sub getDesk{
555 return $USERS{$Group};
556 }

Once again... how is that related?
my question: why is there no print outout on line 62 of display.pl?

There *is* output printed there. $desk is assigned a literal value, so
there's no possibility of it being empty.

What's happening to that output after it's printed is an option question,
and impossible to determine from the tiny snippets of code you've given
us to work with.

sherm--
 
W

William

in accmgr:
How is that related to what's in display.pl?

in display.pl, i am calling accmgr with the action of "getDesk", which
runs the elsif on line 71.


accmgr:
Once again... how is that related?

line 72 of accmgr calls getDesk of accmgr (line 554-556), then returns the
value to line 61 of display.pl.

but in line 62 of display.pl, nothing gets printed.

WHY?
 
D

Dr.Ruud

William schreef:
61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
62 print $desk;

my question: why is there no print outout on line 62 of display.pl?
i.e. print $desk;

Is there a select-call active?
perldoc -f select
 
S

Sherm Pendley

William said:
but in line 62 of display.pl, nothing gets printed.

WHY?

As I said before, it's:

Have you read the posting guidelines that appear here frequently? They
suggest posting the smallest *working* example that *illustrates* the
problem. You haven't done that. You've simply copied some lines that may
or may not be relevant, out of a script you're assuming everyone here is
familiar with.

No one here can help you, unless you help us help you.

sherm--
 
W

William

to illustrate display.pl:

1 #!/usr/bin/perl
2
3 require "../accmgr";
4
5 use Sys::Hostname;
6 use File::Basename;
7 use File::stat;
8 use Time::localtime;
9 use CGI;
10 use CGI::Carp qw(fatalsToBrowser);
11
12 print "Content-type: text/html\n\n";
13 print "<html><title>Form Upload</title><body>\n";
14
15
16 $file = "/mkapp/webapps/mxrt/html/upload_repo.html";
17
18 open(IN, "$file");
19 @lines = <IN>;
20 close(IN);
21
22 print @lines;
23
24 # need to get accmgr to pass the userid's desk back to this file
25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
26 print $desk;
27
28 ############ use $desk to dynamically generate the set of radio
buttons
29 # loop thru $file
30 # if <IN> = <input type="radio" name="desk"
value="BO"> BO
31 # compare value to (e.g. $desk ?= BO )
32 # if not match, skip this line
33 # if match, print this line
34
35 print "</body></html>";

accmgr:


#!/usr/bin/perl

# accmgr
#
# The script manages the access (login/passwords/ACL) to define which
users
# have access to what functionality. In addition, it supports self
# registration and password changes.

require "./mxrt_vars.pl";
require "./mxrt_auth.pl";
require "/mkapp/webapps/mxrt-cgi/dbConn.pl";


use File::stat;
use File::Basename;
use Time::Local;
#use Time::localtime;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $query = new CGI;

@GROUPS = qw(BO FO LFO SYS);


sub loadUserCfg {
$USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;

open(USERCFGFILE, "<$MXUSERCFGFILE") or
return "Unable to access User config file:".$MXUSERCFGFILE."<br>
Please try again later.";

%USERS = ();
undef @USER_DETAIL_KEYS;
undef @USER_DETAIL_VALS;
while (<USERCFGFILE>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
if ($var eq "UserID") {
# this is the header definitions
@USER_DETAIL_KEYS = split(':', $value);
#print "@USER_DETAIL_KEYS"."<br>";
}
else {
@USER_DETAIL_VALS = split(':', $value);
#print "@USER_DETAIL_VALS"."<br>";
my $count=0;
foreach $key (@USER_DETAIL_KEYS) {
$USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
}
}
}
close USERCFGFILE;

#foreach $user (keys %USERS) {
# foreach $key (@USER_DETAIL_KEYS) {
# print $user, $key, $USERS{$user}{$key}, "<br>";
# }
#}

return "";
}


# get the desk from user.cfg and return this desk to display.pl to
show/hide radio buttons
sub getDesk{
return $USERS{$Group}; # $Group is one of {BO FO LFO SYS}
}



How is that related to what's in display.pl?

in display.pl, i am calling accmgr with the action of "getDesk", which
runs the elsif on line 71.


accmgr:
Once again... how is that related?

line 72 of accmgr calls getDesk of accmgr (line 554-556), then returns the
value to line 61 of display.pl.

but in line 62 of display.pl, nothing gets printed.

WHY?
 
S

Sherm Pendley

Upside-down - please stop that. Haven't you read the posting guidelines yet?
to illustrate display.pl:

What's up with the line numbers? This is Perl, not BASIC.
1 #!/usr/bin/perl

Always ask Perl for as much help as it can give you.

use strict;
use warnings;

These should appear first, so the CGI::Carp will be able to tell you if
one of the other uses or requires fails.
9 use CGI;
10 use CGI::Carp qw(fatalsToBrowser);
2
3 require "../accmgr";
4
5 use Sys::Hostname;
6 use File::Basename;
7 use File::stat;
8 use Time::localtime;
11
12 print "Content-type: text/html\n\n";
13 print "<html><title>Form Upload</title><body>\n";
14
15
16 $file = "/mkapp/webapps/mxrt/html/upload_repo.html";
17
18 open(IN, "$file");

# Always - yes, *ALWAYS* check the return value of open()
# Also, quoting $file is unnecessary here - see "perldoc -q always"

open(IN, $file) or die "Could not open $file: $!";
19 @lines = <IN>;
20 close(IN);
21
22 print @lines;
23
24 # need to get accmgr to pass the userid's desk back to this file
25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';

This will print the string you've assigned to $desk above. Is it printing
something else? Did you *expect* it to print something else? If so, what
did you expect it to print?

Use your browser's "view source" function to view what's actually being
printed - if there is broken and/or missing HTML markup, there could be
text that your browser isn't showing you.

I *think* what you might be expecting is a call to the getDesk() function
that's found in accmgr - if that's the case, then you're *way* off track,
and you need to have a look at:

perldoc -f require
perldoc perlsub
perldoc perlmod

sherm--
 
J

Joe Smith

William said:
25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
26 print $desk;

Do you understand the distinction between

$desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';

and

$desk=`/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk`;

? And are you aware that one CGI program cannot call another
CGI program using the syntax you're using?

It appears that you are under the mistaken impression that
a perl script treats URLs the same way that a browser does.

For URLs pointing to an external server, use LWP::Simple.
For CGI scripts running on the same server as the perl script,
you have to set up the right environment before executing
the second script, and use either backticks or pipe to read
the results.

-Joe
 
W

William

I have modified the syntax to the following:
#!/usr/bin/perl

require "../accmgr";

# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk();
print $desk;


where getDesk() is in accmgr:

554 sub getDesk{
555 return $USERS{$Group};
556 }

Still, $USERS{$Group} is not being printed for print $desk

I did set up the environment before running the CGI script.
 
P

Paul Lalli

William said:
I have modified the syntax to the following:

You've modified *what* syntax? Please quote enough of the thread so we
know what you're talking about.
#!/usr/bin/perl

You have forgotten
use strict;
and
use warnings;
require "../accmgr";

# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk();
print $desk;


where getDesk() is in accmgr:

554 sub getDesk{
555 return $USERS{$Group};
556 }

Still, $USERS{$Group} is not being printed for print $desk

Where is %USERS defined? Where is $Group defined?
I did set up the environment before running the CGI script.

How, exactly? Are you assuming your CGI script is run with the same
environment as your local account?

Have you read the posting guidelines for this group? They are posted
here twice a week. Among other good advice, they tell you you should
post a SHORT but COMPLETE script that illustrates your problem.

Paul Lalli
 
W

William

More details:

#!/usr/bin/perl
use strict;
use warnings;

require "../accmgr";

# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk();
print $desk;

$USERS is defined in the following:
257 sub loadUserCfg {
258 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
259
260 open(USERCFGFILE, "<$MXUSERCFGFILE") or
261 return "Unable to access User config
file:".$MXUSERCFGFILE."<br> Please try again later.";
262
263 %USERS = ();
264 undef @USER_DETAIL_KEYS;
265 undef @USER_DETAIL_VALS;
266 while (<USERCFGFILE>) {
267 chomp; # no newline
268 s/#.*//; # no comments
269 s/^\s+//; # no leading white
270 s/\s+$//; # no trailing white
271 next unless length; # anything left?
272 my ($var, $value) = split(/\s*=\s*/, $_, 2);
273 if ($var eq "UserID") {
274 # this is the header definitions
275 @USER_DETAIL_KEYS = split(':', $value);
276 #print "@USER_DETAIL_KEYS"."<br>";
277 }
278 else {
279 @USER_DETAIL_VALS = split(':', $value);
280 #print "@USER_DETAIL_VALS"."<br>";
281 my $count=0;
282 foreach $key (@USER_DETAIL_KEYS) {
283 $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
284 }
285 }
286 }
287 close USERCFGFILE;
288
289 #foreach $user (keys %USERS) {
290 # foreach $key (@USER_DETAIL_KEYS) {
291 # print $user, $key, $USERS{$user}{$key}, "<br>";
292 # }
293 #}
294
295 return "";
296 }

Groups are defined in the following:
49 @GROUPS = qw(BO FO LFO SYS);
 
B

Brian Wakem

William said:
554 sub getDesk{
555 return $USERS{$Group};
556 }

Still, $USERS{$Group} is not being printed for print $desk
Paul Lalli wrote:
Where is %USERS defined? Where is $Group defined?
$USERS is defined in the following:
257 sub loadUserCfg {
258 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
259
260 open(USERCFGFILE, "<$MXUSERCFGFILE") or
261 return "Unable to access User config
file:".$MXUSERCFGFILE."<br> Please try again later.";
262
263 %USERS = ();
Groups are defined in the following:
49 @GROUPS = qw(BO FO LFO SYS);


So $Groups is never defined, hence $USERS{$Group} is not defined, so trying
to print it prints nothing.
 
W

William

So $Groups is never defined, hence $USERS{$Group} is not defined, so trying
to print it prints nothing.

I have modified my code as follows:

in accmgr:

26 $USERID="AULC2";

565 sub getDesk() {
571 return $USERS{$USERID}{"Group"}; # $key=BO/FO/LFO/;
572 }

$USERS is filled out in the following subroutine:

258 sub loadUserCfg {
259 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
260
261 open(USERCFGFILE, "<$MXUSERCFGFILE") or
262 return "Unable to access User config
file:".$MXUSERCFGFILE."<br> Please try again later.";
263
264 %USERS = ();
265 undef @USER_DETAIL_KEYS;
266 undef @USER_DETAIL_VALS;
267 while (<USERCFGFILE>) {
268 chomp; # no newline
269 s/#.*//; # no comments
270 s/^\s+//; # no leading white
271 s/\s+$//; # no trailing white
272 next unless length; # anything left?
273 my ($var, $value) = split(/\s*=\s*/, $_, 2);
274 if ($var eq "UserID") {
275 # this is the header definitions
276 @USER_DETAIL_KEYS = split(':', $value);
277 #print "@USER_DETAIL_KEYS"."<br>";
278 }
279 else {
280 @USER_DETAIL_VALS = split(':', $value);
281 #print "@USER_DETAIL_VALS"."<br>";
282 my $count=0;
283 foreach $key (@USER_DETAIL_KEYS) {
284 $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
285 if ( $key eq "Group" && $var eq $USERID )
286 {
287 print $USERS{$var}{$key}; # prints BO
288 print "\n";
289 # print $var;
290 # print "\n";
291 # print $key;
292 # print "\n";
293 }
294 }
295 }
296 }
297 close USERCFGFILE;
298
299 #foreach $user (keys %USERS) {
300 # foreach $key (@USER_DETAIL_KEYS) {
301 # print $user, $key, $USERS{$user}{$key}, "<br>";
302 # }
303 #}
304
305 return "";
306 }


in display.pl:

#!/usr/bin/perl
use strict;
use warnings;

require "../accmgr";

# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk;
print $desk;

problem: "print $desk;" gives no output
expected output: BO (see line 287 of display.pl as above)

I am basically trying to call accmgr::getDesk() from display.pl, to fill
the $desk in display.pl.

I have read:
perldoc -f perlsub
perldoc -f require

perldoc -q subroutine

but couldn't solve the "no output" problem.
 
B

Brian Wakem

William said:
# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk;
print $desk;


Bareword "getdesk" not allowed while "strict subs" in use at -e line 1.

Let perl help you find the errors.
 
W

William

Bareword "getdesk" not allowed while "strict subs" in use at -e line 1.

Let perl help you find the errors.

Global symbol "$desk" requires explicit package name at ./test.pl line 8.
Execution of ./test.pl aborted due to compilation errors.

what explicit package do i need?

- i already checked perldoc -q package
 
W

William

Global symbol "$desk" requires explicit package name at ./test.pl line 8.
Execution of ./test.pl aborted due to compilation errors.

what explicit package do i need?

- i already checked perldoc -q package

background and source code:
in accmgr:

26 $USERID="AULC2";

565 sub getDesk() {
571 return $USERS{$USERID}{"Group"}; # $key=BO/FO/LFO/;
572 }

$USERS is filled out in the following subroutine:

258 sub loadUserCfg {
259 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
260
261 open(USERCFGFILE, "<$MXUSERCFGFILE") or
262 return "Unable to access User config
file:".$MXUSERCFGFILE."<br> Please try again later.";
263
264 %USERS = ();
265 undef @USER_DETAIL_KEYS;
266 undef @USER_DETAIL_VALS;
267 while (<USERCFGFILE>) {
268 chomp; # no newline
269 s/#.*//; # no comments
270 s/^\s+//; # no leading white
271 s/\s+$//; # no trailing white
272 next unless length; # anything left?
273 my ($var, $value) = split(/\s*=\s*/, $_, 2);
274 if ($var eq "UserID") {
275 # this is the header definitions
276 @USER_DETAIL_KEYS = split(':', $value);
277 #print "@USER_DETAIL_KEYS"."<br>";
278 }
279 else {
280 @USER_DETAIL_VALS = split(':', $value);
281 #print "@USER_DETAIL_VALS"."<br>";
282 my $count=0;
283 foreach $key (@USER_DETAIL_KEYS) {
284 $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
285 if ( $key eq "Group" && $var eq $USERID )
286 {
287 print $USERS{$var}{$key}; # prints BO
288 print "\n";
289 # print $var;
290 # print "\n";
291 # print $key;
292 # print "\n";
293 }
294 }
295 }
296 }
297 close USERCFGFILE;
298
299 #foreach $user (keys %USERS) {
300 # foreach $key (@USER_DETAIL_KEYS) {
301 # print $user, $key, $USERS{$user}{$key}, "<br>";
302 # }
303 #}
304
305 return "";
306 }


in display.pl:

#!/usr/bin/perl
use strict;
use warnings;

require "../accmgr";

# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk;
print $desk;

problem: "print $desk;" gives no output
expected output: BO (see line 287 of display.pl as above)

I am basically trying to call accmgr::getDesk() from display.pl, to fill
the $desk in display.pl.

I have read:
perldoc -f perlsub
perldoc -f require

perldoc -q subroutine

but couldn't solve the "no output" problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top