| | |
Why my shell script doesn't delete a file ??
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
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.
#!/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.
•
•
Join Date: Jan 2005
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Comatose
the html page is probably being run as "nobody" or another user of the sort. do an ls -l on the file you are trying to remove, and check the permissions, and the ownership of the file. If the permissions are not set correctly.... it won't remove the file.
Ok, And The permissions are set correctly (700, or 755 or something like that) so that the owner has permissions to delete?
Also, This seems silly that it would have any effect, but try making the shell script remove the file WITHOUT using the variable.... try it with a literal and see if it removes the file. If it does, then it's something with the variable, if it doesn't.... well, it's something else.
Also, This seems silly that it would have any effect, but try making the shell script remove the file WITHOUT using the variable.... try it with a literal and see if it removes the file. If it does, then it's something with the variable, if it doesn't.... well, it's something else.
![]() |
Similar Threads
- Help in writing a shell script (Shell Scripting)
- Shell script Help (Shell Scripting)
- c++ or shell script to delete some files (C++)
Other Threads in the Shell Scripting Forum
- Previous Thread: Passing a variable with a password to the SU command
- Next Thread: script for search SUID/GUID !
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting






