For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > November 2005 > implementing links on a system command output









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author implementing links on a system command output
DBSMITH@OhioHealth.com

2005-10-12, 6:55 pm

I have written a CGI Perl program that allows my users to view relevant
data.
The data is produced by a Unix application command and I have told it to
write to a intranet page that looks like:

|------|
| ( ) |
|------|All-Clients
|------|
| ( ) |
|------|Backup-Tapes
|------|
| ( ) |
|------|PACS-Fuji
|------|
| (*) |
|------|Heartlab
|------|
| ( ) |
|------|StreamLine-Health
|------|
| ( ) |
|------|Archiver-Status
|------|
| ( ) |
|------|Tape-Drive-Status
|------|
| ( ) |
|------|Tape-Capacity



fs_heartlab.1


sort:path


media: sg


Volumes:


H01190


H01191


H01192


H01193


Total space available: 74.0G





What I want to do now is create a link using CGI Perl for each H string
that will pull a different data set either on a new page or on the same
page embedded.
Originally I just created another radio button for the new data set, but
there will be 6 different views (6 different strings) and I already have 7
buttons (minus the Tape-Capacity button) and I do not want to "button out"
myself or the users.

I looked in the CGI Programming with Perl and saw an entry in there on page
269 referencing access.conf and in access.conf you enter a line with

Action Tracker /cgi/track.cgi

Can anyone help?

thx
derek

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams


DBSMITH@OhioHealth.com

2005-10-14, 6:55 pm


Derek
Smith/Staff/OhioH
ealth To
<beginners-cgi@perl.org>
10/12/2005 05:52 cc
PM
Subject
implementing links on a system
command output












I have written a CGI Perl program that allows my users to view relevant
data.
The data is produced by a Unix application command and I have told it to
write to a intranet page that looks like:

|------|
| ( ) |
|------|All-Clients
|------|
| ( ) |
|------|Backup-Tapes
|------|
| ( ) |
|------|PACS-Fuji
|------|
| (*) |
|------|Heartlab
|------|
| ( ) |
|------|StreamLine-Health
|------|
| ( ) |
|------|Archiver-Status
|------|
| ( ) |
|------|Tape-Drive-Status
|------|
| ( ) |
|------|Tape-Capacity



fs_heartlab.1


sort:path


media: sg


Volumes:


H01190


H01191


H01192


H01193


Total space available: 74.0G





What I want to do now is create a link using CGI Perl for each H string
that will pull a different data set either on a new page or on the same
page embedded.
Originally I just created another radio button for the new data set, but
there will be 6 different views (6 different strings) and I already have 7
buttons (minus the Tape-Capacity button) and I do not want to "button out"
myself or the users.

I looked in the CGI Programming with Perl and saw an entry in there on page
269 referencing access.conf and in access.conf you enter a line with

Action Tracker /cgi/track.cgi

Can anyone help?

thx
derek

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams


****************************************
****************************************
***********



Can anyone respond please ????


Greg Jetter

2005-10-14, 6:55 pm

On Friday October 14 2005 11:21 am, DBSMITH@OhioHealth.com wrote:
> Derek
> Smith/Staff/OhioH
> ealth To
> <beginners-cgi@perl.org>
> 10/12/2005 05:52 cc
> PM
> Subject
> implementing links on a system
> command output
>
>
>
>
>
>
>
>
>
>
>
>
> I have written a CGI Perl program that allows my users to view relevant
> data.
> The data is produced by a Unix application command and I have told it to
>
> write to a intranet page that looks like:
> |------|
> | ( ) |
> |------|All-Clients
> |------|
> | ( ) |
> |------|Backup-Tapes
> |------|
> | ( ) |
> |------|PACS-Fuji
> |------|
> | (*) |
> |------|Heartlab
> |------|
> | ( ) |
> |------|StreamLine-Health
> |------|
> | ( ) |
> |------|Archiver-Status
> |------|
> | ( ) |
> |------|Tape-Drive-Status
> |------|
> | ( ) |
> |------|Tape-Capacity
>
> fs_heartlab.1
>
>
> sort:path
>
>
> media: sg
>
>
> Volumes:
>
>
> H01190
>
>
> H01191
>
>
> H01192
>
>
> H01193
>
>
> Total space available: 74.0G
>
>
>
>
>
> What I want to do now is create a link using CGI Perl for each H string
> that will pull a different data set either on a new page or on the same
> page embedded.
> Originally I just created another radio button for the new data set, but
> there will be 6 different views (6 different strings) and I already have 7
> buttons (minus the Tape-Capacity button) and I do not want to "button out"
> myself or the users.
>
> I looked in the CGI Programming with Perl and saw an entry in there on page
> 269 referencing access.conf and in access.conf you enter a line with
>
> Action Tracker /cgi/track.cgi
>
> Can anyone help?
>
> thx
> derek
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
> ****************************************
***********************************
>****************
>
>
>
> Can anyone respond please ????


I'm not getting your problem ... The page you referenced in that book refers
to setting up the apache web server to handle state saving extra path info.
basicaly your linking a requested url to a cgi script. at the server level.

have fun , me I'd just make each string produced into a clickable link that
would produce another page directly.

Greg
Chris Devers

2005-10-14, 6:55 pm

On Fri, 14 Oct 2005 DBSMITH@OhioHealth.com wrote:

> I have written a CGI Perl program that allows my users to view
> relevant data.
>
> The data is produced by a Unix application command and I have told it
> to write to a intranet page that looks like:


What it looks like is irrelevant. The raw HTML is a little bit relevant,
but the really relevant thing is the data that gets sent to the script
and the results that are expected to be returned from the script.

> What I want to do now is create a link using CGI Perl for each H
> string that will pull a different data set either on a new page or on
> the same page embedded.
>
> Originally I just created another radio button for the new data set,
> but there will be 6 different views (6 different strings) and I
> already have 7 buttons (minus the Tape-Capacity button) and I do not
> want to "button out" myself or the users.
>
> I looked in the CGI Programming with Perl and saw an entry in there on
> page 269 referencing access.conf and in access.conf you enter a line
> with
>
> Action Tracker /cgi/track.cgi
>
> Can anyone help?


I'm sorry, I'm by the question.

You seem to want help organizing how data is presented to and retrieved
from the user of your web application, but then you're asking a CGI list
how to go about doing advanced apache web server configuration. How was
the access.conf suggestion supposed to help solve this problem?

IF the answer to your problem is to start mucking around with Apache
directives -- and so far I'm not convinced that it is -- then putting
those directives in access.conf is outdated advice anyway. Modern Apache
administration tends to have people put everything in httpd.conf so that
there's one file to look in; some people break things into separate conf
files that httpd.conf includes, but this generally isn't how it's done
by people just getting started with apache administration now.

In any case, it isn't clear to me how this was supposed to solve your
problem to begin with. What were you hoping would happen if you changed
the behavior of /cgi/track.cgi in Apache? I think you're better off just
concentrating on your HTML and CGI code for now, and leave mucking with
the web server for later.

Reduce the problem to a flow of desired inputs and outputs. The inputs
are generally going to be forms in plain HTML documents or as generated
by the output from CGI scripts; the outputs will generally be generated
from CGI scripts, though in some cases could be static HTML, too. You
may want to sketch things out on paper rather than just blindly start
coding things. If some part of the input system is doing too much or is
too confusing for users or maintainers, then break it apart as needed.

You seem to be asking general systems design questions without giving
enough material to clarify what the system is doing now or how it is
supposed to be working differently in the future. This is only
tangentally a CGI question; your first priority here seems to be to sort
out exactly how this is all supposed to be interoperating in the first
place. Once you have a clearer sense of that, implementing the specific
components of the system should get easier for you.


--
Chris Devers
DBSMITH@OhioHealth.com

2005-10-14, 6:55 pm


Jay Savage
<daggerquill@gmai
l.com> To
beginners-cgi@perl.org
10/14/2005 11:56 cc
AM
Subject
Re: implementing links on a system
command output













On 10/14/05, Chris Devers <cdevers@pobox.com> wrote:
> On Fri, 14 Oct 2005 DBSMITH@OhioHealth.com wrote:
>
>
> What it looks like is irrelevant. The raw HTML is a little bit relevant,
> but the really relevant thing is the data that gets sent to the script
> and the results that are expected to be returned from the script.
>
>
> I'm sorry, I'm by the question.
>
> You seem to want help organizing how data is presented to and retrieved
> from the user of your web application, but then you're asking a CGI list
> how to go about doing advanced apache web server configuration. How was
> the access.conf suggestion supposed to help solve this problem?
>
> IF the answer to your problem is to start mucking around with Apache
> directives -- and so far I'm not convinced that it is -- then putting
> those directives in access.conf is outdated advice anyway. Modern Apache
> administration tends to have people put everything in httpd.conf so that
> there's one file to look in; some people break things into separate conf
> files that httpd.conf includes, but this generally isn't how it's done
> by people just getting started with apache administration now.
>
> In any case, it isn't clear to me how this was supposed to solve your
> problem to begin with. What were you hoping would happen if you changed
> the behavior of /cgi/track.cgi in Apache? I think you're better off just
> concentrating on your HTML and CGI code for now, and leave mucking with
> the web server for later.
>
> Reduce the problem to a flow of desired inputs and outputs. The inputs
> are generally going to be forms in plain HTML documents or as generated
> by the output from CGI scripts; the outputs will generally be generated
> from CGI scripts, though in some cases could be static HTML, too. You
> may want to sketch things out on paper rather than just blindly start
> coding things. If some part of the input system is doing too much or is
> too confusing for users or maintainers, then break it apart as needed.
>
> You seem to be asking general systems design questions without giving
> enough material to clarify what the system is doing now or how it is
> supposed to be working differently in the future. This is only
> tangentally a CGI question; your first priority here seems to be to sort
> out exactly how this is all supposed to be interoperating in the first
> place. Once you have a clearer sense of that, implementing the specific
> components of the system should get easier for you.
>
>
> --
> Chris Devers
>


And at the risk of sounding more Chris than Chris on this thread:

What have you tried?
Where did it go wrong?
Where's your code?

I have to say, I'm not getting this either. Is your question about
getting CGI.pm to generate dynamic content based on system command
output? Or is your question simply how to declutter a page full of
radio buttons? Or is your question something else entirely?

Whichever it is, giving some specific code you're having trouble with
will get you a better, more useful answer faster, if only because it
makes what you're trying to do clearer. But then you should really
know that by now.

--jay

****************************************
*******************************

ok I apologize for the apache access.conf file question, my confusion which
is the whole problem.
I have no new code b/c in my CGI book I cannot find anything that would
give me a kickstart on generating code other that using the common <A HREF>
tag.

what I want is exactly what Greg stated: "me I'd just make each string
produced into a clickable link that
would produce another page directly."

Is there an equivalent cgi.pm method to <A HREF> and if so will someone
write a brief snippet?

thank you,

derek


Greg Jetter

2005-10-14, 6:55 pm

On Friday October 14 2005 12:07 pm, DBSMITH@OhioHealth.com wrote:
> Jay Savage
> <daggerquill@gmai
> l.com> To
> beginners-cgi@perl.org
> 10/14/2005 11:56 cc
> AM
> Subject
> Re: implementing links on a system
> command output
>
> On 10/14/05, Chris Devers <cdevers@pobox.com> wrote:
>
> And at the risk of sounding more Chris than Chris on this thread:
>
> What have you tried?
> Where did it go wrong?
> Where's your code?
>
> I have to say, I'm not getting this either. Is your question about
> getting CGI.pm to generate dynamic content based on system command
> output? Or is your question simply how to declutter a page full of
> radio buttons? Or is your question something else entirely?
>
> Whichever it is, giving some specific code you're having trouble with
> will get you a better, more useful answer faster, if only because it
> makes what you're trying to do clearer. But then you should really
> know that by now.
>
> --jay
>
> ****************************************
*******************************
>
> ok I apologize for the apache access.conf file question, my confusion which
> is the whole problem.
> I have no new code b/c in my CGI book I cannot find anything that would
> give me a kickstart on generating code other that using the common <A HREF>
> tag.
>
> what I want is exactly what Greg stated: "me I'd just make each string
> produced into a clickable link that
> would produce another page directly."
>
> Is there an equivalent cgi.pm method to <A HREF> and if so will someone
> write a brief snippet?
>
> thank you,
>
> derek


using the oop method
try somthing like this:

#--- code
use CGI;
use strict;
my $q = new CGI;

# pass your info like the script name and params to the script like

my $String = "/path/url.pl?H_String";

print $q->header , $q->start_html ;
print $q->p(<a href="$String">I'm the generated link </a> ) ;
print $q->end_html ;

#-- end code
might need an extra set of quoats around the <a> tag , havn't tested so don't
know.

you could also do it several other ways , hell it's perl :)

hope this helps ya .

Greg

DBSMITH@OhioHealth.com

2005-10-14, 6:55 pm


Greg Jetter
<greg@lazymountai
n.com> To
beginners-cgi@perl.org
10/14/2005 02:46 cc
PM
Subject
Re: implementing links on a system
command output













On Friday October 14 2005 12:07 pm, DBSMITH@OhioHealth.com wrote:
> Jay Savage
> <daggerquill@gmai
> l.com>

To
> beginners-cgi@perl.org
> 10/14/2005 11:56

cc
> AM
>

Subject
> Re: implementing links on a system
> command output
>
> On 10/14/05, Chris Devers <cdevers@pobox.com> wrote:
relevant,[color=darkred]
on[color=darkred]
list[color=darkred]
Apache[color=darkred]
that[color=darkred]
conf[color=darkred]
just[color=darkred]
sort[color=darkred]
>
> And at the risk of sounding more Chris than Chris on this thread:
>
> What have you tried?
> Where did it go wrong?
> Where's your code?
>
> I have to say, I'm not getting this either. Is your question about
> getting CGI.pm to generate dynamic content based on system command
> output? Or is your question simply how to declutter a page full of
> radio buttons? Or is your question something else entirely?
>
> Whichever it is, giving some specific code you're having trouble with
> will get you a better, more useful answer faster, if only because it
> makes what you're trying to do clearer. But then you should really
> know that by now.
>
> --jay
>
> ****************************************
*******************************
>
> ok I apologize for the apache access.conf file question, my confusion

which
> is the whole problem.
> I have no new code b/c in my CGI book I cannot find anything that would
> give me a kickstart on generating code other that using the common <A

HREF>
> tag.
>
> what I want is exactly what Greg stated: "me I'd just make each string
> produced into a clickable link that
> would produce another page directly."
>
> Is there an equivalent cgi.pm method to <A HREF> and if so will someone
> write a brief snippet?
>
> thank you,
>
> derek


using the oop method
try somthing like this:

#--- code
use CGI;
use strict;
my $q = new CGI;

# pass your info like the script name and params to the script like

my $String = "/path/url.pl?H_String";

print $q->header , $q->start_html ;
print $q->p(<a href="$String">I'm the generated link </a> ) ;
print $q->end_html ;

#-- end code
might need an extra set of quoats around the <a> tag , havn't tested so
don't
know.

you could also do it several other ways , hell it's perl :)

hope this helps ya .

Greg


--
****************************************
******

awesome... thanx dude.... I will try this!

derek




DBSMITH@OhioHealth.com

2005-10-18, 9:55 pm


Greg Jetter
<greg@lazymountai
n.com> To
beginners-cgi@perl.org
10/14/2005 02:46 cc
PM
Subject
Re: implementing links on a system
command output













On Friday October 14 2005 12:07 pm, DBSMITH@OhioHealth.com wrote:
> Jay Savage
> <daggerquill@gmai
> l.com>

To
> beginners-cgi@perl.org
> 10/14/2005 11:56

cc
> AM
>

Subject
> Re: implementing links on a system
> command output
>
> On 10/14/05, Chris Devers <cdevers@pobox.com> wrote:
relevant,[color=darkred]
on[color=darkred]
list[color=darkred]
Apache[color=darkred]
that[color=darkred]
conf[color=darkred]
just[color=darkred]
sort[color=darkred]
>
> And at the risk of sounding more Chris than Chris on this thread:
>
> What have you tried?
> Where did it go wrong?
> Where's your code?
>
> I have to say, I'm not getting this either. Is your question about
> getting CGI.pm to generate dynamic content based on system command
> output? Or is your question simply how to declutter a page full of
> radio buttons? Or is your question something else entirely?
>
> Whichever it is, giving some specific code you're having trouble with
> will get you a better, more useful answer faster, if only because it
> makes what you're trying to do clearer. But then you should really
> know that by now.
>
> --jay
>
> ****************************************
*******************************
>
> ok I apologize for the apache access.conf file question, my confusion

which
> is the whole problem.
> I have no new code b/c in my CGI book I cannot find anything that would
> give me a kickstart on generating code other that using the common <A

HREF>
> tag.
>
> what I want is exactly what Greg stated: "me I'd just make each string
> produced into a clickable link that
> would produce another page directly."
>
> Is there an equivalent cgi.pm method to <A HREF> and if so will someone
> write a brief snippet?
>
> thank you,
>
> derek


using the oop method
try somthing like this:

#--- code
use CGI;
use strict;
my $q = new CGI;

# pass your info like the script name and params to the script like

my $String = "/path/url.pl?H_String";

print $q->header , $q->start_html ;
print $q->p(<a href="$String">I'm the generated link </a> ) ;
print $q->end_html ;

#-- end code
might need an extra set of quoats around the <a> tag , havn't tested so
don't
know.

you could also do it several other ways , hell it's perl :)

hope this helps ya .

Greg
****************************************
************************************

Perl'ers,

I tried this solution and it is not working. There are no errors but the
output is not displaying the links for every $_ which is H02000 for
example.

I do not understand what "/path/url.pl?H_String"; is.
what is the ? before H_string for and why

understand that the H_string will be generated from a system command for
every $_
and it looks like

sf.H02047 capacty: 189.1G space: 117.7G

Here is my code snippet

sub viewhrtlab
{
open (ARC, "archiver -v |") or error();
foreach (<ARC> )
{
print "<H3>";
if (/(?i)fs_heartlab\.1/ ..
/(?i)fs_lanv1.1/)
{
s<fs_lanv1.1><>;
$flag=1;
if ($flag==1)
{
if (/(?i)total
space available:/)
{
print
"<p><b><font color=#0000CC><u>$_";
}
else {
print
"<p><A HREF=$_></p></b></font></u></A>";
#print
"<p></b></font></u>$_";
}
}


Greg Jetter

2005-10-19, 3:55 am

On Tuesday October 18 2005 10:09 pm, DBSMITH@OhioHealth.com wrote:
snip
>*
>
> Perl'ers,
>
> I tried this solution and it is not working. There are no errors but the
> output is not displaying the links for every $_ which is H02000 for
> example.
>
> I do not understand what "/path/url.pl?H_String"; is.
> what is the ? before H_string for and why

when invoking a script via http say a script called processSomthing.pl ,
The "?" symbol tells the script and webserver that what follows is a name
value ppair of CGI values , example would be , say I've got a script that
im invoking in a url call "processName.pl" and my url might be
www.somplace.com/cgi-bin/processName.pl , The way I'd pass values to it
would be by doing somthing like
www.somplace.com/cgi-bin/processNam...t=frakinquacker .

in your case If you got a script to produce additional output and your trying
to pass a value you could do somthing like the above. Just one way of many.




>
> understand that the H_string will be generated from a system command for
> every $_
> and it looks like
>
> sf.H02047 capacty: 189.1G space: 117.7G
>
> Here is my code snippet
>
> sub viewhrtlab
> {
> open (ARC, "archiver -v |") or error();
> foreach (<ARC> )
> {
> print "<H3>";
> if (/(?i)fs_heartlab\.1/ ..
> /(?i)fs_lanv1.1/)
> {
> s<fs_lanv1.1><>;
> $flag=1;
> if ($flag==1)
> {
> if (/(?i)total
> space available:/)
> {
> print
> "<p><b><font color=#0000CC><u>$_";
> }
> else {
> print
> "<p><A HREF=$_></p></b></font></u></A>";
> #print
> "<p></b></font></u>$_";
> }
> }


what are you trying to do with the value in $_ ?
if its not a call to another cgi program why make a link out of it ?

In the example you gave the result appears to be a <a> tag
with the destination of "sf.H02047 capacty: 189.1G space: 117.7G" , this
would look like

<a href="sf.H02047 capacty: 189.1G space: 117.7G"> </a> which does nothing
and might not be what your shooting for.

if your looking to produce a page that just displays the value of $_ . you
need to create a new page and use the value of $_ as the text on that new
page not make that text a link to nowhere .


with out more info , I can only guess what your trying to do.


Good luck

Greg


Charles K. Clarkson

2005-10-19, 3:55 am

DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: I do not understand what "/path/url.pl?H_String"; is.

It looks like a CGI GET request. Like this one for Google.

http://groups.google.com/groups?q=%...i+column%22+css


: what is the ? before H_string for and why

It is used to separate the cgi script name from the list of
fields. I think RFC 2396 explains URIs.


: understand that the H_string will be generated from a system
: command for every $_ and it looks like
:
: sf.H02047 capacty: 189.1G space: 117.7G

Can you show more examples. (Is capacity really spelled wrong
in the code?). This one will fail in the code you gave. (Well,
everything will fail in the code given, but assuming a complete
code example was given, this example would fail.) How about five
that should fail to print and five that should succeed and print
a link.

Here's how I would write the code for a question to a list.
Note how I replaced the I/O with <DATA>. I don't care how you get
the data, as long as you are sure the sample is an accurate
sample.

You can then just add the examples at the bottom of the script
below the __END__ tag. Then we can all cut and paste the script to
our editors and see your problem first hand.

Note that I deleted the "open' statement, the extra comments,
that $flag business, simplified the html, and added strict and
warnings. All the distractions are out of the way and we can find
what problem you are really having. As soon as we have some
sample data.



#!/usr/bin/perl

use strict;
use warnings;

viewhrtlab();

sub viewhrtlab {

foreach ( <DATA> ) {

if ( /(?i)fs_heartlab\.1/ .. /(?i)fs_lanv1.1/ ) {
s<fs_lanv1.1><>;

if (/(?i)total space available:/) {
print "<p>$_</p>";

} else {
print qq(<p><a href="$_"></a></p>\n";
}
}
}
}

__END__
sf.H02047 capacity: 189.1G space: 117.7G
Charles K. Clarkson

2005-10-20, 6:55 pm

DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: ok here is what I am trying to do. In the atached doc it shows
: output from my perl cgi program ...

You sent this as a MS Word document. When I open it, Word
converts it to a word web view and when I view the code I get a
Word trashed html file listing. Can you send this as a raw text
file instead? The Word format is pretty useless.

<excerpt>

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<link rel=Original-File href="file:///FOOBAR%20on%20links.doc">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="FOOBAR%20on%20links_files/filelist.xml">
<link rel=Edit-Time-Data href="FOOBAR%20on%20links_files/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}

</excerpt>

Not what I think really came out of your CGI script.



[snip]


: sf.H02047 capacity: 189.1G space: 117.7G.

[snip]


: Is this more clearer?

No. I still don't have more than the above sample of what an
H string is. You also haven't shown source code that allows me to
answer your need, and you have not restated the problem you are
having. I am not going back into the thread to find out what your
problem is.

Let's go back to the beginning.

1 - Show me what is you are starting with. Use a large sample.
Not just one input. Be that a file or a list or whatever.

2 - Show me the results you expect the script to display.

3 - Show me what you have got for code so for. Edit out any
sensitive items like passwords and things.

Don't send these back as anything but raw text files. Do not
send Word documents. I'd like to help but you are giving much of
the wrong information. Lean toward giving us too much information
rather than too little.


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

DBSMITH@OhioHealth.com

2005-10-21, 6:55 pm


"Charles K.
Clarkson"
<cclarkson@htcomp To
.net> <beginners-cgi@perl.org>
cc
10/20/2005 07:35
PM Subject
RE: implementing links on a system
command output













DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: ok here is what I am trying to do. In the atached doc it shows
: output from my perl cgi program ...

You sent this as a MS Word document. When I open it, Word
converts it to a word web view and when I view the code I get a
Word trashed html file listing. Can you send this as a raw text
file instead? The Word format is pretty useless.

<excerpt>

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<link rel=Original-File href="file:///FOOBAR%20on%20links.doc">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="FOOBAR%20on%20links_files/filelist.xml">
<link rel=Edit-Time-Data href="FOOBAR%20on%20links_files/editdata.mso">
<!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:*
{behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape
{behavior:url(#default#VML);}</excerpt> Not what I think really came out
of your CGI script.[snip]: sf.H02047 capacity: 189.1G space: 117.7G.[snip]:
Is this more clearer? No. I still don't have more than the above sample
of what anH string is. You also haven't shown source code that allows me to
answer your need, and you have not restated the problem you arehaving. I am
not going back into the thread to find out what yourproblem is. Let's go
back to the beginning. 1 - Show me what is you are starting with. Use a
large sample. Not just one input. Be that a file or a list or
whatever. 2 - Show me the results you expect the script to display. 3
- Show me what you have got for code so for. Edit out any sensitive
items like passwords and things. Don't send these back as anything but
raw text files. Do notsend Word documents. I'd like to help but you are
giving much ofthe wrong information. Lean toward giving us too much
informationrather than too little.HTH,Charles K. Clarkson-- Mobile Homes
Specialist254 968-8328-- To unsubscribe, e-mail:
beginners-cgi-unsubscribe@perl.orgFor additional commands, e-mail:
beginners-cgi-help@perl.org<http://learn.perl.org/> <
http://learn.perl.org/first-response>
****************************************
****************************************
****************************************
**************************************
****************************************
****************************************
****************************************
**************************************

ok beginning it is......

I am starting with a view from a radio button that displays how much space
is remaining in each pool labeled as fs_heartlab.1 and fs_heartlab.2.
Under these headings are H strings and from each H string I am trying to
set-up a link to push me to another page that displays a data set as such:
sf.H02047 capacity: 189.1G space: 117.7G.
The difficulty is that $_ is an entire block of data that includes more
than just H strings and therefore I cannot link all of $_ which is why I
placed just the H strings
from $_ in an array. From this array, I was thinking of traversing
through, running the command to get the capacity data.

thx for the persistence!




HERE IS $_
********************

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G

FUTURE RESULTS FROM THIS LINK.....
OR Here is the "new" data set:
****************************************
************************

sg.H01192 capacity: 39.1G space: 31.4G -il-o-b-----
sg.H01193 capacity: 20.0G space: 20.0G -il-o-b-----
sg.H01195 capacity: 20.0G space: 20.0G -il-o-b-----
sg.H01196 capacity: 20.0G space: 20.0G -il-o-b-----
sg.H01197 capacity: 20.0G space: 20.0G -il-o-b-----


##### BEGIN CODE #####

use strict;
use warnings;
use CGI qw(:standard), (-unique_headers);
use CGI::Carp qw(fatalsToBrowser);
use MIME::Lite ();
our $flag=0;
my $time = localtime;
$ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin);
delete @ENV{qw (IFS CDPATH BASH_ENV) };
$| =1; ##-- Turn off buffering --##

##-- BEGIN MAIN CGI ##--##

my $q = new CGI;
print $q->header,
$q->start_html ('OhioHealth I.S. ASM server: stkv440'),
# Header
$q->h1 ({-style=>'Color:blue'},'OhioHealth ASM Intranet Page:');
# Body

##-- Print the 1st form --##

print $q->hr;

print $q->startform;

print "<P><H3>Please Select a View Below for ASM Tape Pool Status or System
Status. </P></H3>",

$q->radio_group
..
..
..

viewhrtlab();
my @Harray=();
my $i=0;
my ($H9840vols,$H9940vols) =0;
#my $SF='sf.';
sub viewhrtlab
{
open (ARC, "archiver -v |") or error();
foreach (<ARC> )
{
print "<H3>";
if (/(?i)fs_heartlab\.1/ ..
/(?i)fs_lanv1.1/)
{
s<fs_lanv1.1><>;
$flag=1;
if ($flag==1)
{
if (/(?i)total
space available:/)
{
print
"<p><b><font color=#0000CC><u>$_";
}
else {
#print
"<p><A HREF=$_></p></b></font></u></A>";
print
"<p></b></font></u>$_";
}
if ( /(?i)h01/g )
{
$H9840vols++;
$Harray[$i++] = $_;
}
if ( /(?i)h02/g )
{
$H9940vols++;
}
}

} ##-- END FORLOOP ON LINE 565 --##
print @Harray,"\n";

close (ARC) or warn "Was unable to close FH
at line 593 $!";



(See attached file: FOOBAR on links II.txt)
Charles K. Clarkson

2005-10-21, 6:55 pm

DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: The difficulty is that $_ is an entire block of data that
: includes more than just H strings and therefore I cannot link
: all of $_ which is why I placed just the H strings from $_ in an
: array. From this array, I was thinking of traversing
: through, running the command to get the capacity data.

Here's what I am gleaming from your words.

When you say $_ you are referring to this part of the script:

open (ARC, "archiver -v |") or error();
foreach (<ARC> )
{

"archiver -v |" returns this.

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G

So, as a test case, we can use this script. DATA is the same
as ARC above, but now everyone on this list can play with the
code. I use 'while' instead of 'foreach' because it is the more
common idiom in this situation.

#!/usr/bin/perl

use strict;
use warnings;

while ( <DATA> ) {
# do something
}

__END__

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G


Now, if I am not mistaken your task is to strip only the
"H strings" from this list and place it into an array. Since I am
mentally unable to name an array variable with a name containing
the word "array", I will be using the name @h_strings.

#!/usr/bin/perl

use strict;
use warnings;

my @h_strings;
while ( <DATA> ) {
chomp;
push @h_strings, $1 if /\s*(H\d{5})/i;
}

print "$_\n" foreach @h_strings;

__END__

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G

Now @h_strings contains this. Which I believe provides you
with the array you needed to run your command.

H01192
H01193
H01195
H01196
H01197
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041

To step through the array, you could use foreach.

foreach my $h_string ( @h_strings ) {
# Do something with $h_string.
}


If you want to do it all in one step, this would work.

#!/usr/bin/perl

use strict;
use warnings;

while ( <DATA> ) {
chomp;
next unless /\s*(H\d{5})/i;

my $h_string = $1;
# Do something with $h_string.
}

__END__

To translate that back to your subroutine, we would do this.

sub viewhrtlab {

# Don't clobber ARC if it is already open somewhere else.
local *ARC;

open (ARC, "archiver -v |") or error();

while ( <ARC> ) {
chomp;
next unless /\s*(H\d{5})/i;

my $h_string = $1;

# Do something with $h_string.
}
}

HTH,


Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328




DBSMITH@OhioHealth.com

2005-10-21, 6:55 pm


"Charles K.
Clarkson"
<cclarkson@htcomp To
.net> <beginners-cgi@perl.org>
cc
10/21/2005 12:24
PM Subject
RE: implementing links on a system
command output













DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: The difficulty is that $_ is an entire block of data that
: includes more than just H strings and therefore I cannot link
: all of $_ which is why I placed just the H strings from $_ in an
: array. From this array, I was thinking of traversing
: through, running the command to get the capacity data.

Here's what I am gleaming from your words.

When you say $_ you are referring to this part of the script:

open (ARC, "archiver -v |") or error();
foreach (<ARC> )
{

"archiver -v |" returns this.

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G

So, as a test case, we can use this script. DATA is the same
as ARC above, but now everyone on this list can play with the
code. I use 'while' instead of 'foreach' because it is the more
common idiom in this situation.

#!/usr/bin/perl

use strict;
use warnings;

while ( <DATA> ) {
# do something
}

__END__

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G


Now, if I am not mistaken your task is to strip only the
"H strings" from this list and place it into an array. Since I am
mentally unable to name an array variable with a name containing
the word "array", I will be using the name @h_strings.

#!/usr/bin/perl

use strict;
use warnings;

my @h_strings;
while ( <DATA> ) {
chomp;
push @h_strings, $1 if /\s*(H\d{5})/i;
}

print "$_\n" foreach @h_strings;

__END__

fs_heartlab.1
sort:path
media: sg
Volumes:
H01192
H01193
H01195
H01196
H01197
Total space available: 111.3G

fs_heartlab.2
sort:path
media: sf
Volumes:
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041
Total space available: 527.8G

Now @h_strings contains this. Which I believe provides you
with the array you needed to run your command.

H01192
H01193
H01195
H01196
H01197
H02047
H02048
H02051
H02052
H02000
H02039
H02040
H02041

To step through the array, you could use foreach.

foreach my $h_string ( @h_strings ) {
# Do something with $h_string.
}


If you want to do it all in one step, this would work.

#!/usr/bin/perl

use strict;
use warnings;

while ( <DATA> ) {
chomp;
next unless /\s*(H\d{5})/i;

my $h_string = $1;
# Do something with $h_string.
}

__END__

To translate that back to your subroutine, we would do this.

sub viewhrtlab {

# Don't clobber ARC if it is already open somewhere else.
local *ARC;

open (ARC, "archiver -v |") or error();

while ( <ARC> ) {
chomp;
next unless /\s*(H\d{5})/i;

my $h_string = $1;

# Do something with $h_string.
}
}

HTH,


Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
****************************************
**************
****************************************
**************

thx Charles, but your code is something I did knew already.
I need to implement a link for each H string and I do not see this??? I
think we are part way there as in producing the capacity data sets from the
array, but my problem was
the <A HREF> with pointing to another page using "file.pl?H_string"

So in the FH reference local *ARC;
once its open, I can just reuse the reference right? Does the FH have to
still be open in order to reuse it?

*FH is a typeglob?
\*FH is a reference?

cant I assign either one to a scalar?
what is the difference between the two?





--
To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
For additional commands, e-mail: beginners-cgi-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Charles K. Clarkson

2005-10-21, 6:55 pm

DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: thx Charles, but your code is something I did knew (sic) already.
: I need to implement a link for each H string and I do not see
: this???

I assume by "implement a link" you mean that you want to
create an HTML ANCHOR tag for each H String. After re-reading your
original question on this thread I think you are looking for more
than just an anchor tag. You also need a method to retrieve
"capacity data sets" after a link has been followed.

Here is my solution.

my $url = 'capacity.pl?hstring';

my @links;
foreach my $h_string ( @h_strings ) {
push @links,
$q->a(
{ href=> "$url=$h_string" },
$h_string
);
}

print
$q->ul(
$q->li( \@links ),
);


# in capacity.pl

#!/usr/bin/perl

use strict;
use warnings;

use CGI;

my $q = CGI->new();

my $h_string = $q->param( 'hstring' );

print
$q->header(),
$q->start_html( "Capacity Data for $h_string" ),
$q->p( capcity_data( $h_string ) ),
$q->end_html;

sub capcity_data {
my $h_string = shift;

#
# Do that thing you do to get capacity data and
# deposit the result in $capacity_data.
#

return $capacity_data;
}

__END__



: So in the FH reference local *ARC;
: once its open, I can just reuse the reference right? Does the
: FH have to still be open in order to reuse it?

I don'tknow what you are asking. For more info on why I
added "local *ARC;" read this article.

http://perl.plover.com/local.html#2...zed_Filehandles



HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

DBSMITH@OhioHealth.com

2005-11-04, 6:55 pm


"Charles K.
Clarkson"
<cclarkson@htcomp To
.net> <beginners-cgi@perl.org>
cc
10/21/2005 06:29
PM Subject
RE: implementing links on a system
command output













DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: thx Charles, but your code is something I did knew (sic) already.
: I need to implement a link for each H string and I do not see
: this???

I assume by "implement a link" you mean that you want to
create an HTML ANCHOR tag for each H String. After re-reading your
original question on this thread I think you are looking for more
than just an anchor tag. You also need a method to retrieve
"capacity data sets" after a link has been followed.

Here is my solution.

my $url = 'capacity.pl?hstring';

my @links;
foreach my $h_string ( @h_strings ) {
push @links,
$q->a(
{ href=> "$url=$h_string" },
$h_string
);
}

print
$q->ul(
$q->li( \@links ),
);


# in capacity.pl

#!/usr/bin/perl

use strict;
use warnings;

use CGI;

my $q = CGI->new();

my $h_string = $q->param( 'hstring' );

print
$q->header(),
$q->start_html( "Capacity Data for $h_string" ),
$q->p( capcity_data( $h_string ) ),
$q->end_html;

sub capcity_data {
my $h_string = shift;

#
# Do that thing you do to get capacity data and
# deposit the result in $capacity_data.
#

return $capacity_data;
}

__END__



: So in the FH reference local *ARC;
: once its open, I can just reuse the reference right? Does the
: FH have to still be open in order to reuse it?

I don'tknow what you are asking. For more info on why I
added "local *ARC;" read this article.

http://perl.plover.com/local.html#2...zed_Filehandles



HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

****************************************
********************************
****************************************
********************************

Ok after a few mods, I got this working wherein each hstring is a link to
capacity.pl
which is supposed to run and gather the capacity data, but I am getting
"page not found" and in the URL it is displaying:

http://stkv440.ohnet/cgi-bin/=%20%20%20H01196

So it sounds like to me capacity.pl is not being opened and executed.
In the code:

my $url = 'capacity.pl?hstring';

my @links;
foreach my $h_string ( @h_strings ) {
push @links,
$q->a(
{ href=> "$url=$h_string" },
$h_string
);
}

print
$q->ul(
$q->li( \@links ),
);

__END_CODE__

the a href is supposed to be opening and executing this capacity.pl file,
but it is not???
my permissions and ownership are correct on this file and the system app
command permissions
and ownership bits are ok.
my command string in capacity.pl that is getting the capacity data looks
like:

my $capacity_data = (grep /${SF}${h_string},grep s/[-,silobdER]//g,
`archiver -v`);

One last thing I noticed.... if I take off the reference to the array
@links then the elements appear
as one link, but each its own h_string as so:

Is it b/c we are saying print the entire array as opposed to with a
reference it is printing each element or the ref???? whats the diff???

H01196 H01194 H01198 H01200 H01201 H01202

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams

thank you!



DBSMITH@OhioHealth.com

2005-11-08, 6:55 pm

Nevermind on this problem, I fixed it but will be in touch.

thx.
derek

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams





Derek
Smith/Staff/OhioH
ealth To
beginners-cgi@perl.org
11/04/2005 03:08 cc
PM
Subject
RE: implementing links on a system
command output(Document link: Derek
Bellner Smith)













"Charles K.
Clarkson"
<cclarkson@htcomp To
.net> <beginners-cgi@perl.org>
cc
10/21/2005 06:29
PM Subject
RE: implementing links on a system
command output










DBSMITH@OhioHealth.com <mailto:DBSMITH@OhioHealth.com> wrote:

: thx Charles, but your code is something I did knew (sic) already.
: I need to implement a link for each H string and I do not see
: this???

I assume by "implement a link" you mean that you want to
create an HTML ANCHOR tag for each H String. After re-reading your
original question on this thread I think you are looking for more
than just an anchor tag. You also need a method to retrieve
"capacity data sets" after a link has been followed.

Here is my solution.

my $url = 'capacity.pl?hstring';

my @links;
foreach my $h_string ( @h_strings ) {
push @links,
$q->a(
{ href=> "$url=$h_string" },
$h_string
);
}

print
$q->ul(
$q->li( \@links ),
);


# in capacity.pl

#!/usr/bin/perl

use strict;
use warnings;

use CGI;

my $q = CGI->new();

my $h_string = $q->param( 'hstring' );

print
$q->header(),
$q->start_html( "Capacity Data for $h_string" ),
$q->p( capcity_data( $h_string ) ),
$q->end_html;

sub capcity_data {
my $h_string = shift;

#
# Do that thing you do to get capacity data and
# deposit the result in $capacity_data.
#

return $capacity_data;
}

__END__



: So in the FH reference local *ARC;
: once its open, I can just reuse the reference right? Does the
: FH have to still be open in order to reuse it?

I don'tknow what you are asking. For more info on why I
added "local *ARC;" read this article.

http://perl.plover.com/local.html#2...zed_Filehandles



HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

****************************************
********************************
****************************************
********************************

Ok after a few mods, I got this working wherein each hstring is a link to
capacity.pl
which is supposed to run and gather the capacity data, but I am getting
"page not found" and in the URL it is displaying:

http://stkv440.ohnet/cgi-bin/=%20%20%20H01196

So it sounds like to me capacity.pl is not being opened and executed.
In the code:

my $url = 'capacity.pl?hstring';

my @links;
foreach my $h_string ( @h_strings ) {
push @links,
$q->a(
{ href=> "$url=$h_string" },
$h_string
);
}

print
$q->ul(
$q->li( \@links ),
);

__END_CODE__

the a href is supposed to be opening and executing this capacity.pl file,
but it is not???
my permissions and ownership are correct on this file and the system app
command permissions
and ownership bits are ok.
my command string in capacity.pl that is getting the capacity data looks
like:

my $capacity_data = (grep /${SF}${h_string},grep s/[-,silobdER]//g,
`archiver -v`);

One last thing I noticed.... if I take off the reference to the array
@links then the elements appear
as one link, but each its own h_string as so:

Is it b/c we are saying print the entire array as opposed to with a
reference it is printing each element or the ref???? whats the diff???

H01196 H01194 H01198 H01200 H01201 H01202

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams

thank you!




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com