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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why my shell script doesn't delete a file ???

Status
Not open for further replies.

garlam

Programmer
Oct 15, 2004
10
IT
I wrote this shell script:

#!/bin/sh

PATH=/sbin:/usr/bin:/usr/sbin; export PATH

echo "Content-type: text/html"
echo ""

ROOT=/app/webchecker/controller
FILEIN=$ROOT/log/servcheckerstat.txt
FILEDOWN=$ROOT/bin/down_
FILEOUT=/tmp/wcHtmlStat.$$
$ROOT/bin/servckhtmlstat W $FILEIN $FILEDOWN $FILEOUT $QUERY_STRING
cat $FILEOUT
rm -f $FILEOUT
exit 0

servckhtmlstat is a C program which do all the job and write the file.

The problem is:

the shell script doesn't remove the temporary file .... why ????

P.S

I call the script from an html page.
 
No, in the error log there is nothing about that.

The path for rm command is absolute, $FILEOUT is /tmp/...
 
You may, for debugging purpose, add this after the echo "" line:
exec 2>/tmp/wcHtmlStat.err.$$; set -x

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I don't know what

exec 2>/tmp/wcHtmlStat.err.$$;

could do

 
exec 2>/tmp/wcHtmlStat.err.$$
Redirect all the sterr output to the specified file
set -x
Trace all the execution to stderr

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Just a note to check the obvious...

When you call servckhtmlstat, it tells the apache webserver to dump stats to the file you specify. This is done by the apache user, so the file is owned by the apache user.

If you run are running this script under a different user, your own user for example, the file will be created, but you will not have permissions to delete or otherwise edit the file ($FILEOUT)

My advice would be to check the user permissions of the resulting file, and remove the '-f' from the rm command so at least you get a reason printed to your console when you run the command (-f tells 'rm' to be silent).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top