From: | "Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com> |
---|---|
To: | "Ron Johnson" <ron(dot)l(dot)johnson(at)cox(dot)net> |
Cc: | "PgSQL Novice ML" <pgsql-novice(at)postgresql(dot)org>, pgsql-novice-owner(at)postgresql(dot)org |
Subject: | Re: Copy entire file as one field |
Date: | 2002-12-04 19:10:57 |
Message-ID: | OF1049C80F.B7F2D8D9-ON86256C85.00691E38@ipaper.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I just tested this right off the command line and it works fine:
drajput$ for f in `ls ~drajput/tmp/mail/*`; do psql -d counterpointtest -c
"INSERT INTO mail(message) VALUES('`cat $f`')";done
^^^^^^^^^^^^^
db name
regards
Devinder Rajput
Stores Division Corporate Offices
Chicago, IL
(773) 442-6474
"Ron Johnson"
<ron(dot)l(dot)johnson(at)cox(dot)net To: "PgSQL Novice ML" <pgsql-novice(at)postgresql(dot)org>
> cc:
Sent by: Subject: Re: [NOVICE] Copy entire file as one field
pgsql-novice-owner(at)pos
tgresql.org
12/04/2002 12:40 PM
On Wed, 2002-12-04 at 12:16, Warren Massengill wrote:
> The revised version has the same result. If I change the name of the
script
> (another poster suggested avoiding the reserved word 'merge') there is a
> different error message.
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(at)localhost pg]$ merge
> merge: not enough arguments
> merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2
file3
> merge aborted
> --------------------------------------
> [kelly(at)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.
> > >
> > > Somehow I failed to translate your instructions...
> > >
> > > -----------------------------------------------------
> > > #!/bin/bash
> > >
> > > for f in `ls /home/kelly/message*`
> > ^^^^^^
> > message/*
> >
> > > do
> > > psql -d pg -c "INSERT INTO mail (message)
> > > VALUES ('`cat $f`')"
> > > done
> >
> >Your files are in that directory, so the wild card must be too.
> >--
--
+------------------------------------------------------------+
| Ron Johnson, Jr. mailto:ron(dot)l(dot)johnson(at)cox(dot)net |
| Jefferson, LA USA http://members.cox.net/ron.l.johnson |
| |
| "they love our milk and honey, but preach about another |
| way of living" |
| Merle Haggard, "The Fighting Side Of Me" |
+------------------------------------------------------------+
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
From | Date | Subject | |
---|---|---|---|
Next Message | Warren Massengill | 2002-12-04 20:10:58 | Re: Copy entire file as one field |
Previous Message | Warren Massengill | 2002-12-04 19:08:50 | Re: Copy entire file as one field |