LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Ambiguous Redirect Error (https://www.linuxquestions.org/questions/linux-general-1/ambiguous-redirect-error-98072/)

AMMullan 09-28-2003 10:40 PM

Ambiguous Redirect Error
 
I am trying to get a script to write to a log file so I setup the script like so:

#! /bin/bash

LOG=/home/ammullan/daily.log

# Cleanup files
if [ -a $LOG ] ; then
rm $LOG
fi

# Main report header
echo "Daily Report for $HOSTNAME for" `date '+%A, %B %d %Y'`"." >> $LOG
echo "********************************************" >> $LOG
echo >> $LOG

# OS header
echo "Current Operating System" >> $LOG
echo "********************************************" >> $LOG
uname -sr >> $LOG
echo >> $LOG

# Uptime Header
echo "Uptime" >> $LOG
echo "********************************************" >> $LOG
uptime >> $LOG
echo >> $LOG

BUT...
It keeps coming up with the following error:

./good_log: line 20: $LOG: ambiguous redirect
./good_log: line 21: $LOG: ambiguous redirect....

Can anyone help? I know that if I just replaced $LOG with /home/ammullan/daily.log it would work but if I decide to change my UN it would be a pain in the butt :)

:study:
Thanks in advance

DavidPhillips 10-01-2003 08:39 PM

maybe you could put `user` in the place of your username if you want to replace $LOG


I don't know why it would do what your showing unless there's something in the file you can't see



maybe try


echo " " >> $LOG

in Line 18


All times are GMT -5. The time now is 07:43 AM.