I came across very different problem yesterday. I am trying to execute log_path_only.txt by using this command "sh -e log_path_only.txt", It seems to be executed however it is not. I am expecting command line execute log_path_only.txt to remove these static files according to log_path_only.txt once I execute this file. I am using shell as a root and all files permissions is seems to be belongs to root.
log_path_only.txt contains only these lines not anything else
rm -rf /home/mywebsite/www/staticfiles/static-003ae2a3f686d43ec5c3207ec0ae744b-003ae2a3f686d43ec5c3207ec0ae744b-c23c5fbca96e8d641d148bac41017635
rm -rf /home/mywebsite/www/staticfiles/static-00e937fb20315addd5008ebb76134e7e-00e937fb20315addd5008ebb76134e7e-c23c5fbca96e8d641d148bac41017635
rm -rf /home/mywebsite/www/staticfiles/static-00edf2d8a63f1cdc9580092629f580cb-00edf2d8a63f1cdc9580092629f580cb-c23c5fbca96e8d641d148bac41017635
rm -rf /home/mywebsite/www/staticfiles/static-00f1cea6b137132172ad8ea6fc90ab0d-00f1cea6b137132172ad8ea6fc90ab0d-c23c5fbca96e8d641d148bac41017635
[root@www uploads]# ls -l
total 464
-rw-r--r-- 1 root root 0 Oct 19 11:30 148bac41017635
-rw-r--r-- 1 root root 4 Oct 19 11:34 counter.txt
-rw-r--r-- 1 root root 34488 Oct 16 00:15 file_source.txt
-rw-r--r-- 1 root root 204521 Oct 19 11:32 log_both_path_urls.txt
-rw-r--r-- 1 root root 80625 Oct 19 11:32 log_links_only.txt
-rw-r--r-- 1 root root 131184 Oct 19 11:32 log_path_only.txt
[root@www uploads]# sh -e log_path_only.txt
[root@www uploads]#
(I try first static file if its there, yes it is. It is supposed to be deleted)
[root@www uploads]# [ -f /home/mywebsite/www/staticfiles/static-003ae2a3f686d43ec5c3207ec0ae744b-003ae2a3f686d43ec5c3207ec0ae744b-c23c5fbca96e8d641d148bac41017635 ] && echo "File exist" || echo "File does not exist"
File exist
What I tried so far is
1) Copy log_path_only.txt to another place then execute : fail
2) By using cat command to copy contains to another file then execute: fail
3) I changed permission as "chmod +x log_path_only.txt" and try to execute: fail
4) I changed permission as "chmod 777 log_path_only.txt" and then try to execute: fail
5) I open log_path_only.txt by using nano, copy all lines, create a new file and paste everything inside and then execute new file: success
/home/mywebsite/...
files still exist after your attempt to run the file? If so, doeslog_path_only.txt
have DOS line endings? – chepner Oct 19 '17 at 01:12bash
? I don't see a-e
flag in thebash
man pages. – igal Oct 19 '17 at 01:26