The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using Perl to add hyperlink to html files Raynon Shell Programming and Scripting 17 11-01-2007 05:03 AM
HTML parsing by PERL avik1983 Shell Programming and Scripting 3 02-23-2007 09:25 AM
perl and html marcpascual Shell Programming and Scripting 8 09-21-2005 08:47 PM
Perl: Variable input via HTML douknownam Shell Programming and Scripting 5 02-13-2005 11:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-07-2008
i9300 i9300 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 14
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:


Code:
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.


Code:
    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
  #2 (permalink)  
Old 08-07-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,365
If you are comfortable using ksh, use that; forget about perl.
  #3 (permalink)  
Old 08-07-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
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...
  #4 (permalink)  
Old 08-07-2008
i9300 i9300 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 14
Quote:
Originally Posted by Annihilannic View Post
Permissions related? .............
%%*&^*&^ (*(*&^*&^*&^ ^%$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
  #5 (permalink)  
Old 08-07-2008
quine quine is offline
Registered User
  
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 68
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...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0