[Linux-disciples] write to file from shell script

Jamie Forrest jamie at jamieforrest.com
Tue Nov 15 22:02:37 EST 2011


On Tue, Nov 15, 2011 at 9:57 PM, Stephen R Laniel <steve at stevereads.com> wrote:
> What happens if you just dump that output to stdout? Only dump the first few lines, à la
>
> gondor sqldump primary | head
>
> What happens then?

jforrest$ gondor sqldump primary | head
Reading configuration... [ok]
Dumping database... [ok]
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
Traceback (most recent call last):
  File "/Users/jforrest/.virtualenvs/django-cnsltme/bin/gondor", line
9, in <module>
    load_entry_point('gondor==1.0', 'console_scripts', 'gondor')()
  File "/Users/jforrest/.virtualenvs/django-cnsltme/lib/python2.7/site-packages/gondor/__main__.py",
line 740, in main
    }[args.command](args, env, config)
  File "/Users/jforrest/.virtualenvs/django-cnsltme/lib/python2.7/site-packages/gondor/__main__.py",
line 376, in cmd_sqldump
    out(d.decompress(chunk))
  File "/Users/jforrest/.virtualenvs/django-cnsltme/lib/python2.7/site-packages/gondor/utils.py",
line 30, in out
    sys.stdout.write(msg)
IOError: [Errno 32] Broken pipe


>
> On Nov 15, 2011, at 9:28 PM, Jamie Forrest wrote:
>
>> What am I doing wrong? I am trying to write to a file from within a
>> shell script, but the file doesn't get created. Here's the script:
>>
>> #!/bin/bash
>>
>> NOW=`date +%F`
>> gondor sqldump primary > $NOW_dump.sql
>>
>>
>> (For what it's worth gondor sqldump is a command that dumps a remote
>> database to sql (primary is the db instance). Generally when I run it
>> from the cmd line I just run gondor sqldump primary >
>> whatever_dump.sql and all is fine. I know this command is running ok
>> because I see its output "Dumping database... [ok]" when I run the
>> script.)
>>
>> Thanks,
>> Jamie
>> _______________________________________________
>> 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