The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-25-2008
valluvan valluvan is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 27
Log File Writing and Reading

Hi all,
I have the following shell script code which tries to sftp and writes the log into the log file.


Code:
TestConnection ()
{
  echo 'Connection to ' $DESTUSERNAME@$DESTHOSTNAME
  $SETDEBUG
  if [[ -a $SCRIPT ]]; then rm $SCRIPT ; fi
  touch $SCRIPT
  echo "cd" $REMOTEDIR >> $SCRIPT
  echo "quit" >> $SCRIPT
  
  chmod 700 $SCRIPT
  sftp -b $SCRIPT $DESTUSERNAME@$DESTHOSTNAME > $SESSIONLOG
  
  echo '**** FTP log reproduced below:'
  echo '-----------------------------------------------------------'
  cat $SESSIONLOG
  echo '-----------------------------------------------------------'
}

the code executes well and when i manually vi the log file i can see some data written into it...

Whereas the portion of script(cat $SESSIONLOG) does nothing.It prints nothing.Does anyone know what could be the problem?.

I am new to unix and iam thinking is it because iam trying to cat from a file which might be still Open?If yes how do i get around it?

Please help.

Regards