The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
file moving based on file content melvyn.cochrane Shell Programming and Scripting 12 02-15-2008 02:10 AM
Moving lines within a txt file innocentspirit Shell Programming and Scripting 5 09-27-2007 09:04 PM
Problem in moving files to .txt mohdtausifsh UNIX for Advanced & Expert Users 2 03-26-2007 01:04 AM
moving a file? Holistic UNIX for Dummies Questions & Answers 1 02-20-2003 03:47 PM
moving or removing a file rooh UNIX for Dummies Questions & Answers 3 01-01-2002 10:47 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-03-2005
Registered User
 

Join Date: Jun 2005
Location: India
Posts: 5
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-03-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
Stumble this Post!
>> 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.
Reply With Quote
  #3 (permalink)  
Old 06-03-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Stumble this Post!
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
Reply With Quote
  #4 (permalink)  
Old 06-06-2005
Registered User
 

Join Date: Jun 2005
Location: India
Posts: 5
Stumble this Post!
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.
Reply With Quote
  #5 (permalink)  
Old 06-07-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
Stumble this Post!
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.
Reply With Quote
  #6 (permalink)  
Old 06-10-2005
Registered User
 

Join Date: Jun 2005
Location: India
Posts: 5
Stumble this Post!
Thanks Muthukumar for making clear about the problem from user level.

Regards,
S.M.Vel
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0