qiang8
asked on
How to create temp file in remote directory?
How am I going to create temp file in a remote rather than current directory when executing a script because I don't want my directory to look messy with lots of temp file.
For example:
When executing a script in /home/bin, lots of temp files are created here. My quetion is how to create them in a remote directory such as /tmp/garbbage and yet they won't exist in the /home/bin directory.
Thanks........
For example:
When executing a script in /home/bin, lots of temp files are created here. My quetion is how to create them in a remote directory such as /tmp/garbbage and yet they won't exist in the /home/bin directory.
Thanks........
ASKER
My_script resides in /home/bin. When executing the script, some temp files are created and of course these temp files will be deleted (written in the scripts to remove all these temp files after finishing ). During the period of execution, temp files are created within the working directory. During this time, this directory looks messy with all these tenp files.
/home/bin ttime
tmpf tmpp1 ttime* tmpf1 tmppfile
My question is how to make these temp files created/appear only in the /home/garbage but not in the current directory.
/home/bin ttime
ttime* ( No temp files created here while executing the scripts )
/home/garbage
tmpf tmpp1 tmpf1 tmppfile
( temp files were created here )
Thanks.....
/home/bin ttime
tmpf tmpp1 ttime* tmpf1 tmppfile
My question is how to make these temp files created/appear only in the /home/garbage but not in the current directory.
/home/bin ttime
ttime* ( No temp files created here while executing the scripts )
/home/garbage
tmpf tmpp1 tmpf1 tmppfile
( temp files were created here )
Thanks.....
qiang8,
I think I understand your question, but I need some more detail before I can answer it.
1. If you run the script when your pwd is /home/garbbage, where do the temp files appear? If they still appear in /home/bin, then answer question 2.
2. In order to find out if my item c) is the case, could you please temporarily (at least) move the script to /home/garbbage:
mv /home/bin/my_script /home/garbbage
then:
cd /home/garbbage
then run it again:
./my_script
and see where the temp files appear.
If they still appear in /home/bin, then we can be pretty sure that there are hardcoded references to /home/bin in the script, and we will know that the script itself has to be changed.
I await your reply.
I think I understand your question, but I need some more detail before I can answer it.
1. If you run the script when your pwd is /home/garbbage, where do the temp files appear? If they still appear in /home/bin, then answer question 2.
2. In order to find out if my item c) is the case, could you please temporarily (at least) move the script to /home/garbbage:
mv /home/bin/my_script /home/garbbage
then:
cd /home/garbbage
then run it again:
./my_script
and see where the temp files appear.
If they still appear in /home/bin, then we can be pretty sure that there are hardcoded references to /home/bin in the script, and we will know that the script itself has to be changed.
I await your reply.
ASKER
No, they only appear in the pwd. They are not hardcoded references to /home/bin in the script.
.... I want them(temp files) to be hardcoded to /home/garbage ....... so that when I try to do other things in the pwd, I won't get irritated by those garbage temp files.
Pls advise and thanks a lot .......
.... I want them(temp files) to be hardcoded to /home/garbage ....... so that when I try to do other things in the pwd, I won't get irritated by those garbage temp files.
Pls advise and thanks a lot .......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much ...... and is there any way to say set the temp file like this:
set tmp=/home/garbage/temp
(so that temp file are created there )
Thanks.
set tmp=/home/garbage/temp
(so that temp file are created there )
Thanks.
qiang8,
I think so. Then instead of having:
cd /home/garbbage
you could have:
cd $tmp
but I think you would have to "set tmp=..." AND "export tmp" before running the script.
I think so. Then instead of having:
cd /home/garbbage
you could have:
cd $tmp
but I think you would have to "set tmp=..." AND "export tmp" before running the script.
a) If you are saying, the script creates temporary files in the present-working-directory (pwd) of the user, then can you just:
cd /home/garbbage
/home/bin/the_script
b) If you are saying, the script creates temporary files in the directory where it resides, can't you just:
cd /home/bin
mv the_script /home/garbbage
/home/garbbage/the_script
However, this might cause problems for other users of the script, or it might not "like" being run from elsewhere.
Perhaps create a link to the script, from /home/garbbage:
cd /home/garbbage
ln -s /home/bin/the_script the_script
./the_script
c) If you are saying, the script contains explicit references to /home/bin, for it's temporary files, then you would have to change the script.
d) Maybe you could append the script with some lines which delete the temporary files apon completion.
Questions:
1. Which of the above are the case?
2. Are the temporary files a problem to you just for the duration of the script, or do they hang around after it's finished running?
3. Can they be deleted after it's finished running?