In the following code, when I pass variables to get_status my system call is not working. If I hardcode the values in it works. I have used Data::Dumper to pass the variables out to the web page and they look fine, the system call just doesn't run - or perhaps isn't passing the data back to the web page.

#!/usr/bin/perl -T # prtadm.cgi # printer admin page use strict; use warnings; use diagnostics; use CGI qw/:standard/; use POSIX qw(strftime); use Data::Dumper; # For testing # Clean up our UNIX environment # for more infor read perldoc perlsec $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; ####### Declarations ####### my ($SERVER, @LINE, %svr_hash); my (@SERVERS, @TMP_); my $now=strftime "%m/%d/%Y %H:%M:%S", (localtime); my $configfile="/var/www/cgi-bin/prt.cfg"; ### End Declarations ####### ### Pull in configs ### open (CFGFILE,$configfile) || die "unable to open $configfile: $!\n"; foreach $_(<CFGFILE>) { next if /^#/; next if /^\s/; chomp; @TMP_=split(/,/,$_); push (@SERVERS,[ @TMP_ ]); } my @SERVER_LIST=map($_->[0], @SERVERS); for my $i (0 .. $#SERVER_LIST) { $svr_hash{$i} = "$SERVER_LIST[$i]"; } my %rev_srv_num=reverse %svr_hash; ## Start HTML ## print header, start_html; print "<tt><center>",br; print h3("AWI", "Printer", "Administration"); print "$now</center>\n"; print hr,br; ## End of header ## print start_form; print "\n<div align=right>Choose Server",br, popup_menu(-name=>'SERVER', -values=>[@SERVER_LIST], -default=>[$SERVER_LIST[0]]), submit('go'), "\n</div>",br; $SERVER=param('SERVER'); if (param('SERVER')) { print "Server $SERVER is number $rev_srv_num{$SERVER}\n",br; print "is default: @SERVERS[$rev_srv_num{$SERVER}]->[1]\n",br, "print subsystem: @SERVERS[$rev_srv_num{$SERVER}]->[2]\n",br, "connection type: @SERVERS[$rev_srv_num{$SERVER}]->[3]\n",br; get_status("@SERVERS[$rev_srv_num{$SERVER}]->[2]","$SERVER"); #get_status("cups","rlinux1"); } else { print "Error\n";br; } # End else print end_html; sub get_status { my $print_subsystem=shift; # chomp ($print_subsystem); # not needed my $server_name=shift; # chomp ($server_name); # not needed print "you passed $print_subsystem for server $server_name\n",br; print Dumper $print_subsystem; print Dumper $server_name; my @STATUS=`/usr/bin/lpstat -h $server_name -o`; if ( "$print_subsystem" == "cups" ) { for $_(@STATUS) { print "$_ \n",br; } } else { print "unknown subsytem type: $print_subsystem \n",br; } } # end sub get_status

Thanks in advance
Ted

**********UPDATE***********
config file is in the form of:
Server,default,subsytem,connection
ie
server1,no,cups,cups
server2,default,aix,rsh

2005-03-11 Janitored by Arunbear - added readmore tags, as per Monastery guidelines


In reply to passing vars to a sub by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.