[Linux-disciples] write to file from shell script
Jamie Forrest
jamie at jamieforrest.com
Tue Nov 15 22:25:57 EST 2011
Hmm! It works without the exec as well. I wonder what was wrong the last time.
On Tue, Nov 15, 2011 at 10:18 PM, Stephen R Laniel <steve at stevereads.com> wrote:
> Huh. Running 'exec' is basically never the right idea. That's what you run, if I'm not mistaken, when you construct a string using some long combination of things -- I don't know, grep, sed, whatever -- and then need the shell to interpret the string you've just constructed as a command. It wouldn't apply here.
>
> I mean, all you're doing here is
>
> 1. running a command
> 2. dumping the output of that command to a file
>
> , right? No need for exec here. So what happens if you drop the exec?
>
> Also, stick an
>
> echo $logfile
>
> between the 'logfile' line and the 'gondor' line.
>
> On Nov 15, 2011, at 10:15 PM, Jamie Forrest wrote:
>
>> I seem to have solved it as follows:
>>
>> #!/bin/bash
>>
>> logfile=/Users/jforrest/Projects/django-cnsltme/cnsltme/backup/`date
>> +%F`_dump.sql
>> exec gondor sqldump primary > $logfile
>>
>> Is it correct?
>>
>>
>> On Tue, Nov 15, 2011 at 10:08 PM, Adam Rosi-Kessel <adam at rosi-kessel.org> wrote:
>>> On 11/15/2011 10:01 PM, Jamie Forrest wrote:
>>>>
>>>> I'm running it from a subdirectory in my home dir. I tried changing it
>>>> to a full path and still no dice. And yes the output from gondor
>>>> sqldump goes to screen normally.
>>>
>>> Add 2>&1 ?
>>>
>>
>>
>>
>> --
>> http://about.me/jamieforrest
>> _______________________________________________
>> Linux-disciples mailing list
>> Linux-disciples at lists.bostoncoop.net
>> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
>>
>
> --
> Stephen R. Laniel
> steve at stevereads.com
> Cell: +(617) 308-5571
> http://stevereads.com/
> PGP key: http://stevereads.com/slaniel.key
>
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
>
--
http://about.me/jamieforrest
More information about the Linux-disciples
mailing list