I have the following relevant lines in a csh script:
#!/bin/csh -xv
set dvar = `date +"^%m\/%d\/%y"`
set filedate = `date +%b%d%Y`
set grepstring = "grep "\"$dvar\"" </home/user/log/logfile"
set outstring = ">> serverlog_$filedate.txt"
grep "$dvar" <logfile >serverlog_$filedate.txt
ssh SERVER1 \"\"$grepstring\"\" $outstring
The first grep on the local log file works great, but the SSH grep writes its output to the remote directory.
The line is coming out of the batch file as:
ssh SERVER1 ""grep "^01\/05\/10" <home/user/log/logfile"" >> serverlog_Jan052010.txt
When I type it in (with one less set of quotes of course) it works fine, I just can't get this to work from a csh script.
How would you get this command to output to the specified file on the local machine?
EDIT: Here is the final result that worked thanks to womble:
#!/bin/csh
set dvar = `date +"%m\/%d\/%y"`
set filedate = `date +%b%d%Y`
grep "^$dvar" logfile > serverlog_$filedate.txt
ssh SERVER1 grep "^$dvar" /home/user/log/logfile >> serverlog_$filedate.txt