LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to delete a directory in /tmp directory (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-delete-a-directory-in-tmp-directory-4175441406/)

pradeepdee6 12-14-2012 02:12 AM

How to delete a directory in /tmp directory
 
Hi Everyone,

Im creating a directory in /tmp location for temporary storage of files. then i move them to actual folder.

Im not able to delete the directory.
Server Version: AIX dseax203 3 5 00CF1AEC4C00
shell : Bash

Quote:

Code:

#!/usr/bin/ksh
FILEDIR="/opt/proj/rem_fil"

mkdir /tmp/get.$$.Temp
cd /tmp/get.$$.Temp

ftp -n -vi > FTP_LOG.txt
open dseax203
user User Pass
cd mft_test
get abc*
close
quit

chmod 777 abc*
mv /tmp/get.$$.Temp/* $FILEDIR
rm -f /tmp/get.$$.Temp
Please help me how can i delete the directory in /tmp directory.


Thanks in Advance.

colucix 12-14-2012 02:42 AM

You missed the -r (recursion) option of rm, necessary to remove directories. If the directory is empty the rmdir command is enough, otherwise rm -r is mandatory.

pradeepdee6 12-14-2012 03:11 AM

Hi colucix,

Thankyou very much for the reply.

I tried with rm -r, rm -rf. But the result was same, im not able to delete the directory.
Since im moving all the files and the directory will be empty, even then rmdir is not able to deleted teh directory.

when i manually use th ecommand in comand prompt, the directory gets deleted.
But when the same command included in shell script, it ll not be able to delete.

Thanks in Advance

colucix 12-14-2012 03:17 AM

Any error message from the script? What if you change #!/usr/bin/ksh with #!/usr/bin/bash or the exact path to the bash shell, if different?

pradeepdee6 12-14-2012 03:32 AM

Hi colucix,
This is the error message.
Quote:

rm: 0653-610 Cannot remove current directory /tmp/get.15097918.Temp.
#!/usr/bin/bash made no difference.

does /tmp has any special permissions that doesnot allow deleting a directory in it ??

colucix 12-14-2012 03:37 AM

I didn't notice it before, but most likely you have to go out of the directory before removing it.

TobiSGD 12-14-2012 03:40 AM

You can't delete the directory when it is your current working directory. Insert a
Code:

cd -
before the rm command to change the current working directory back to the previous state before removing that directory.

pradeepdee6 12-14-2012 03:41 AM

Thanks you so much Hi colucix.

Quote:

but most likely you have to go out of the directory before removing it.
This was the main reason for my error.

Thanks


All times are GMT -5. The time now is 03:37 PM.