Perl + Korn + HTML

I have a perl script that prints up the html code and executes a few korn scripts to populate the web code.

Disclaimer === I can throw together some korn scripts pretty quick. This code changes pretty frequently. I don't know enough about perl to do everything I need. One day maybe I'll get there but for now -- This does work at least on the web side.

Basically I call a korn script in a variable with tics and print the var inside the html code....
See Below:

Perl Code:
$KSH_CHECK_SCRIPT="scripts/scriptname"; #Check script for UISSssh

foreach (<IN>) {
$HOST="$_";
$KSH_CHECK=`$KSH_CHECK_SCRIPT $HOST`;
print "<tr align=left><th width=20%>$HOST</th><th width=20%>yes</th><th width=20%>yes</th><th width=20%>$KSH_CHECK</th><th width=20%>yes</th></tr>";
}
close IN;

Keep in mind this does work and gives me my expected results. Pretty ? Prob not.

After churning the ksh script, it simply echos y or n
I would like to also echo some output to a file. The script does exactly that and works as designed when I execute either the ksh script by itself or from executing perl script from the command line.

My Problem.....
However when I call the perl script form the browser it will not output the additional info from the ksh script to the text file....

In the example below, it is line 32 the is not being executed when running the perl script from the browser.

    1  #!/bin/ksh
	SNIP out a bunch os variables 
    16  VER=$( sed -n "/$PKG/"'s/.*'"$PKG"'(\([^)]*\)).*/\1/p'  $COLLECT ) ## Thanks JP!
    17
    18  if [[ $VER = $CORRECT_VER ]];then
    19          if [[ $STATUS = N ]];then
    20              continue
    21          else
    22              STATUS=Y
    23          fi
    24  else
    25      STATUS=N
    26      MESSAGE="$MESSAGE Update Needed for ${PKG}:$VER to $CORRECT_VER"
    27  fi
    28
    29  if [[ $STATUS = Y ]];then
    30          echo "$STATUS"
    31  else
    32          print $MESSAGE >> $OUTPUT
    33          echo "$STATUS"
    34  fi 

Again all the will work if I run the perl script form the command line.

Any Ideas?

-Chris

If you are comfortable using ksh, use that; forget about perl.

Permissions related? Are you sure it is being run by a user that has access to append output to that file? Try changing it to print $MESSAGE >> /tmp/somenewfile to test...

%%*&^&^ (*(*&^*&^&^ ^%$654%^$

Ok I'm shaking my head in shame.
Yes permission problems. The since it executed from the web -- It is a different user.

Well thanks very much for pointing out the obvious :slight_smile:

Perl buffers output by default. Maybe when you execute from browser you never see the buffered output. Set $| = 1; (or $AUTOFLUSH = 1) and you will turn off buffering on the CURRENTLY SELECTED FILE HANDLE which I'm guessing is STDOUT anyway when you get to that print statement in the perl script...

Anyway, no harm trying it...