Statements executed out of order? 
Author Message
 Statements executed out of order?

I'm having a very strange problem. In part of my script, I append two
files together to create a new file, close all three files, and use unlink
to delete the two old files.

Then I open the new one for reading, print it to STDOUT, close it, and use
unlink again to delete it.

At least, that's what's supposed to happen. In reality, I get a "requested
URL not found" error on my browser. I assume this is coming from the MIME
'Location:' tag I print just before the file.

What's wierd is that if I comment out the last unlink command, it works
fine. But, this command occurs AFTER the file is supposedly opened,
printed, and closed again! Can anyone tell me what's going on here? Thanks
in advance. Cheers!



Fri, 14 Jan 2000 03:00:00 GMT  
 Statements executed out of order?

This is a cryptographically signed message in MIME format.

--------------ms89C594E1028E14470078D66A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Quote:

> I'm having a very strange problem. In part of my script, I append two
> files together to create a new file, close all three files, and use unlink
> to delete the two old files.

> Then I open the new one for reading, print it to STDOUT, close it, and use
> unlink again to delete it.

> At least, that's what's supposed to happen. In reality, I get a "requested
> URL not found" error on my browser. I assume this is coming from the MIME
> 'Location:' tag I print just before the file.

> What's wierd is that if I comment out the last unlink command, it works
> fine. But, this command occurs AFTER the file is supposedly opened,
> printed, and closed again! Can anyone tell me what's going on here? Thanks
> in advance. Cheers!

I'm not sure I understand what you're doing, but these are my assumptions:
The script is a CGI
The script prints a "Location: (URL)" on the first line of the (HTML) page it
produces,
then prints out the file

Quote:
>From this I would say the following is happening:

The file gets written OK (just like you said). The script sends a "Location:
(URL)" to the browser, which the browser interprets like a "redirect", and tries
to go off and get the file ... which by then is deleted, because Perl is faster
than HTTP. Finally, the file gets printed to STDOUT, and lands in never-never
land (seriously pissing off Peter Pan, no doubt).
So (from what I understand) you need to do is: send only the "Location: (URL)",
and delete the file later (...somehow...), or send a "Content-type: text/html
(or text/plain)\n\n" (the second "\n" is important) to the browser as the first
two lines of the page.
HTH

- chris

--------------ms89C594E1028E14470078D66A
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

<encoded_portion_removed>
nX04zxX/b2eqTt5uxp/uf6zSMfI=
--------------ms89C594E1028E14470078D66A--



Sat, 15 Jan 2000 03:00:00 GMT  
 Statements executed out of order?

Quote:

> What's wierd is that if I comment out the last unlink command, it works
> fine. But, this command occurs AFTER the file is supposedly opened,
> printed, and closed again!

Probably you're a victim of output buffering: Error message are normally
sent at once, while standard output is saved in a buffer. This can cause
an error message to appear in the "wrong" place. Check out the magical $|
variable in perlvar(1). Hope this helps!

--
Tom Phoenix           http://www.teleport.com/~rootbeer/

Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



Sat, 15 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. order of execution of print statements?

2. Print execute order?

3. What is going to happen if prepare SQL statements without executing them

4. Executing a block of statements for each file

5. DBI execute statement

6. DBD::Oracle::st fetchrow_array failed: ERROR no statement executing

7. executing sql statement using pool connections

8. )executing sql statement using pool connections.

9. execute a Perl Programm with DBD:DBI - SQL-Statements in a file

10. execute use statement only on condition

11. HELP!!!!!!!!! IF statement keeps executing

12. Executing a block of statements for each file

 

 
Powered by phpBB® Forum Software