[Linux-disciples] write to file from shell script
Dylan Thurston
dpt at math.cornell.edu
Wed Nov 16 21:39:29 EST 2011
Steve, I think you're confusing 'exec' with 'eval'. 'eval' does what
you say; 'exec' stops execution of the current program and switches to
the new one. I think it would be harmless here, and would save a
small amount of memory.
--Dylan
On Tue, Nov 15, 2011 at 10:18:12PM -0500, Stephen R Laniel 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
>
More information about the Linux-disciples
mailing list