Ok,

I'm still trying to figure out have to run a program in unix from a cgi script. First I wrote a simple program that printed "hi" in a text file then read the text file and printed it out in html. Then I made it so that `ls` was executed, put in the file and then read and printed out. I did this to be sure I was on the right track. Now I want to run a program called lm. It's a tool which I would like to use to update the status of something. My problem is that in an xterm it works fine but in a browser the lm output never makes it to the file. I suspect it has to do with environment variables but i'm not sure. Here's my test code:

#!/usr/bin/perl $hi = `ls`; `setenv LM_DIR /opt/corp/projects/board_simulation/tools/hw_model-3.4/ +sms/lm_dir`; `setenv LM_LIB /opt/corp/projects/board_simulation/tools/hw_model-3.4/ +sms/models:/opt/corp/projects/board_simulation/tools/hw_model-3.4/sms +/maps`; `setenv VCS_LMC_HM_ARCH sun4.solaris`; `setenv LMC_PATH /opt/corp/projects/board_simulation/lib/custom_swift_ +v41`; $lm = `lm show_modeler -m wmers0c3.1`; $logfile = "lmout.txt"; open (FILE, ">$logfile") or die "I can't open that now\n"; print FILE "hi"; print FILE "$hi"; print FILE "$lm"; close(FILE); open (FILE, "$logfile") or die "I can't open that now\n"; while (<FILE>) { push @Contents, $_; } close(FILE); print "Content-type: text/html\n\n"; print "<html>\n <head>\n <title>lm</title>\n </head>\n\n"; print "<body>\n"; foreach $Content(@Contents){ print "$Content<br>"; } print "\n"; print "</body>\n</html>\n";

In reply to calling a unix prog by Max_Glink

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.