Problem while moving a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem while moving a file
# 1  
Old 06-03-2005
Question Problem while moving a file

Dear Friends,

You can easily understand my problem after looking into the code.

test1.sh
--------
#!/bin/sh
LOG_HOME="/home/vel"
while [ TRUE ]
do
echo `date`
done

test2.sh
--------
#!/bin/sh
LOG_HOME="/home/vel"
if [ -s $LOG_HOME/1.log ]
then
sh $LOG_HOME/test1.sh >> $LOG_HOME/1.log
else
touch 1.log
sh $LOG_HOME/test1.sh >> $LOG_HOME/1.log
fi

I will execute test2.sh script. After sometime I will move the 1.log to another directory. The problem is the script is still appending the output of test1.sh to the moved file. It should not happen. 1.log should be newly created in the LOG_HOME and output should be appended to the newly created file.

I have tried some logic. But I couldnt find the solution for solving this problem. Can any one help me out from this?

Note: You can modify test2.sh only.

Thanks in Advance,
S.M.Vel
# 2  
Old 06-03-2005
>> will append or if the file is not there then it creates it again newly. But, It will only append new informations not the old one. You can look it in the new file.

hth.
# 3  
Old 06-03-2005
Quote:
Originally Posted by smvel
Note: You can modify test2.sh only.
Why?!? This wouldn't happen to be a homework problem, would it?

ZB
# 4  
Old 06-06-2005
Muthukumar,

It is appending only in the old file(which is moved to some directory).
Have you tried executing this code?
If you need some more clarification, tell me.
# 5  
Old 06-07-2005
Problem is because of inifite loop in test1.sh. It will keep on appending date informations in to 1.log. It will update the file of 1.log if you move anywhere. Operation is being done with kernel level to update a log file, we can not control from user level by changing locaiton of file.

hth.
# 6  
Old 06-10-2005
Thanks Muthukumar for making clear about the problem from user level.

Regards,
S.M.Vel
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in compressing and moving files

Hi I am writing a sample script (sample.ksh) to compress files in the source directory and move them to another directory. The script takes a config file (files.config) as the paramter the contents of which are as given under: /abc/src ${TSTENV}-xxx-yyy~1.log /abc/src/dest /abc/src... (8 Replies)
Discussion started by: swasid
8 Replies

2. UNIX for Dummies Questions & Answers

Help! With File Moving

Hello, This is my first post, so please forgive my obvious lack of UNIX knowledge. I am trying/needing to write a script that follows this functional flow: 1. Access a config file that contains format:<directory> <filetype> <daterange> <directory> <filetype> <daterange> <directory>... (2 Replies)
Discussion started by: WildBeard83
2 Replies

3. UNIX for Advanced & Expert Users

Need help on moving .csv file from UNIX to windows file path

Need help on moving .csv file from unix to windows file path. (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

4. Shell Programming and Scripting

moving file

Hello ALL, i hope everyone is fine here. I have found some directories that have 777 permission with below command. find ./ -type d -perm 0777 e/uploads/ e/uploads/s1 j/uploads/ j/uploads/s1 I want that if there is any php|html|css file found in above directory so move those... (4 Replies)
Discussion started by: learnbash
4 Replies

5. Shell Programming and Scripting

Problem with moving a file to another dir.

Hi frnds The following is the code #!/bin/ksh ############################################################## # # # Created by eDB Dev - 27-May-2011 # # ... (1 Reply)
Discussion started by: balesh
1 Replies

6. UNIX for Dummies Questions & Answers

Problem to map VIM cursor moving in InsertMode

Hi all What I want? I want in Insert mode, press Alt-hjkl move cursor, and then back to insert mode. I know ctrl-o, hjkl can do the job. but everytime I want to move, i have to press ctrl-o, or I have to count how many hjkl I will do, do a C-O (n)hjkl. What I tried (example only with 'j')... (2 Replies)
Discussion started by: sk1418
2 Replies

7. Shell Programming and Scripting

Need help in finding filesize , moving file , gzipping file

Hi , Please help with the following questions 1) how can i find size of a file ? i have written du -k $flname > s1 . Is this right ? Any other better suggeastions ? 2) how do I use mv command for moving the file ? I need the syntax with some examples 3) Command for printing the total... (1 Reply)
Discussion started by: Learning!
1 Replies

8. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

9. UNIX for Advanced & Expert Users

Problem in moving files to .txt

Hello All Iam running one script to Split the file and rename it with .txt extension Script Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"` split -3000 -a 4 Z_PRICE_NEW.txt $Prefix find . -name "$Prefix*" -print | { while read FILE; do mv $FILE $FILE.tmp done } Since the Source file was... (2 Replies)
Discussion started by: mohdtausifsh
2 Replies

10. UNIX for Dummies Questions & Answers

moving a file?

i'm trying to move a file from one diectory to another and rename it at the same time. but its giving me an error . " mv: cannot unlink /dir2/file5 : No such file or directory" here is the command I'm using. mv /dir1/file1 /dir2/file5 solaris 8 (1 Reply)
Discussion started by: Holistic
1 Replies
Login or Register to Ask a Question