Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl cgi

Status
Not open for further replies.

Jaq

Programmer
Feb 17, 2001
8
0
0
US
my perl cgi program is called with a form, It goes out and chks one file size, if the size has changed it does stuff, that parts ok...but if the file size has not changed I want the script to just die...but it always want to come back and open a window...it doesnt care which window just whatever i tell it with the "print "location: XXX.htm"...If i leave that out it opens a window with a "cannot find file" msg. there must be some way to run a script and then not have it come back knocking on the door.
Thanks
Jaq@QB7.com
 
It's hard to tell without seeing the actual code but you might want to try to put an EXIT command.

if(size == changed)
{
print "Hello !";
}
else
{
exit;
}
 
No...thanks for trying darkom...but that doesnt work...the script generates a window that says "cant find file"
 
Can you put the code in your reply so we can see how it is structured !

 
Well..it appears to be true of any perl cgi program...I have yet to see one that doesnt insist on opening a browser window somewhere along the line. Heres a simplified example..it will open up a window at completion that says the browser cant find the requested window, I just want it to finish its job and die.

#########

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
($strip,$filename) = split(/=/,$buffer);

$sz = -s $filename;
if($sz > 0) {
open (FILE, "$filename");
$nuData=<FILE>;
close (FILE);

open (FILE, &quot;>$filename&quot;); # clear file
close (FILE);

# append new data to storage file
open (DOX,&quot;>>Storage.txt&quot;);
print DOX &quot;$nuData \n&quot;;
close (DOX);
}

exit; # so...how does one end this simple
# script without opening a window?



 
if your goal is to keep the form page in the browser when the file size has not changed, then may I suggest doing this :

if($sz > 0) {
open (FILE, &quot;$filename&quot;);
$nuData=<FILE>;
close (FILE);

open (FILE, &quot;>$filename&quot;); # clear file
close (FILE);

# append new data to storage file
open (DOX,&quot;>>Storage.txt&quot;);
print DOX &quot;$nuData \n&quot;;
close (DOX);
}

else {
print &quot;history.back()&quot;;
}

That will prevent the File not found message. But if a user submits a form he would expect a return to tell him(or her) the result.

I suggest putting a page with the message &quot;the file has not changed !!!&quot; in the else part.

If the cgi just dies then what will the user see ?
The browser expects a return and will always put an error message if you don't tell it otherwise.

Hope that helps. X-)
 
That one opens a window that say &quot;this page cannot be displayed...etc....etc&quot;...
My question isnt really about this script in particular. Let me rephrase it. Does a perl cgi script always open a window, no matter the scripts function?....if not ..where kind I find an example of a perl cgi script that performs any simple function without opening a window.
Thanks for your continued input.
 
In that case try using a standard perl script. (.pl) instead of a cgi. Then you won't have a windows open.

Here is an exemple :

#!/usr/lpp/ssp/perl5/bin/perl

$command_text = &quot;ip_general&quot;;
$command_text = uc($command_text);
print '$command_text\n';
exit;

If you use the line :
use CGI;

then it will probably open a window. I have never seen a CGI used other then for a web page.

 
Ok...thanks for the info..Ill follow that path
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top