Re: Copy entire file as one field - Mailing list pgsql-novice

From Devinder K Rajput
Subject Re: Copy entire file as one field
Date
Msg-id OF444280E6.1528C7D0-ON86256C85.006FCCEC@ipaper.com
Whole thread Raw
In response to Copy entire file as one field  ("Warren Massengill" <warrenmassengill@hotmail.com>)
List pgsql-novice
from the error messages it seems that it can not the bash shell.  One thing
to try is
$ which bash

and see if returns with the location or  just try running the following one
liner  from the command line:

for f in `ls /home/kelly/message/*`;do psql -d pg -c "INSERT INTO mail
(message) VALUES ('`cat $f`')"; done

Devinder Rajput
Stores Division Corporate Offices
Chicago, IL
(773) 442-6474



                    
                      "Warren Massengill"
                    
                      <warrenmassengill@hotm        To:       ron.l.johnson@cox.net
                    
                      ail.com>                      cc:       pgsql-novice@postgresql.org
                    
                      Sent by:                      Subject:  Re: [NOVICE] Copy entire file as one field
                    
                      pgsql-novice-owner@pos
                    
                      tgresql.org
                    

                    

                    
                      12/04/2002 02:10 PM
                    

                    

                    





I'm still missing something.....

Two identical files: merge and merge4; both executable by the world.
------------------------------------
$ ./merge or $ ./merge4
cannot find the file
------------------------------------
$ merge
apparently locates the file -- but cannot run it
------------------------------------
-rw-------    1 kelly    kelly        3062 Dec  3 11:57 logfile
-rwxrwxrwx    1 kelly    kelly         135 Dec  3 13:24 merge
-rwxrwxrwx    1 kelly    kelly         135 Dec  3 10:54 merge4
drwx------    2 kelly    kelly        4096 Dec  2 04:31 pg_clog
-rw-------    1 kelly    kelly       10168 Dec  2 04:31 pg_hba.conf
-rw-------    1 kelly    kelly        1250 Dec  2 04:31 pg_ident.conf
-rw-------    1 kelly    kelly           4 Dec  2 04:31 PG_VERSION
drwx------    2 kelly    kelly        4096 Dec  2 04:31 pg_xlog
-rw-------    1 kelly    kelly        3848 Dec  2 04:31 postgresql.conf
-rw-------    1 kelly    kelly          20 Dec  3 10:51 postmaster.opts
--------------------------------------
[kelly@localhost pg]$ ./merge
: bad interpreter: No such file or directory
[kelly@localhost pg]$ ./merge4
: bad interpreter: No such file or directory
--------------------------------------
[kelly@localhost pg]$ merge
merge: not enough arguments
merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2
file3
merge aborted
[kelly@localhost pg]$
--------------------------------------

Thanks,
Warren

>
>You *must* run your script this way:
>$ ./merge4
>
>And you did make sure that the script is executable, right?
>
> > ------------------------------------
> > #!/bin/bash
> >
> > for f in `ls /home/kelly/message/*`
> > do
> >         psql -d pg -c "INSERT INTO mail (message)
> >                                  VALUES ('`cat $f`')"
> > done
> >
> > -------------------------------------
> > [kelly@localhost pg]$ merge
> > merge: not enough arguments
> > merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2
>file3
> > merge aborted
> > --------------------------------------
> > [kelly@localhost pg]$ merge4
> > bash: merge4: command not found
> > --------------------------------------
> > >
> > >On Tue, 2002-12-03 at 19:48, Warren Massengill wrote:
> > > > My database is pg, the table is mail.
> > > > The small text files are in /home/kelly/message/.
> > > > The bash shell script is merge.

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster







pgsql-novice by date:

Previous
From: "Patrick Hatcher"
Date:
Subject: Re: Vacuum full error No one parent tuple
Next
From: Oliver Elphick
Date:
Subject: Re: Yet one more stupid question