Not exactly a grass question, but I figured you all might see what I'm doing wrong. I am trying load a postgis db that is connected to grass.
in order to do so, I'd like to automate the 100 or so files that need to be read into the db with a \copy process from a bash script. See below:
#!/bin/sh
for infile in /Volumes/disk7/b4warmed3/export/60min2/*.csv
do
cat infile | psql -h localhost dbname -c "\copy table1 FROM stdin with delimiter as ',' NULL AS 'NA' CSV HEADER"
done
I'm getting an error about the name of the file I'm building to then copy from into the db.
Does this approach require that I create the file "infile" first? And if so, in what directory? Or does someone see some ridiculously stupid mistake I'm making?
Here's the error:
[kirkw@truffula]bin$ ./b4warmed_loader
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
Hi Kirk!
I think it's just a bash-syntax error. Try
for SomeVariable in WhatEver; do
-------------------------------------------^^^
notice the " ; "
Best, Nikos
Kirk Wythers wrote:
Not exactly a grass question, but I figured you all might see what I'm doing
wrong. I am trying load a postgis db that is connected to grass.
in order to do so, I'd like to automate the 100 or so files that need to be
read into the db with a \copy process from a bash script. See below:
#!/bin/sh
for infile in /Volumes/disk7/b4warmed3/export/60min2/*.csv
do
cat infile | psql -h localhost dbname -c "\copy table1 FROM stdin with
delimiter as ',' NULL AS 'NA' CSV HEADER" done
I'm getting an error about the name of the file I'm building to then copy
from into the db.
Does this approach require that I create the file "infile" first? And if so,
in what directory? Or does someone see some ridiculously stupid mistake I'm
making?
Here's the error:
[kirkw@truffula]bin$ ./b4warmed_loader
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
Hi, the problem is here:cat infile
You need to write: cat $infile
Απο: Kirk Wythers kirk.wythers@gmail.com
Προς: grass-user grass-user grass-user@lists.osgeo.org
Στάλθηκε: 9:23 μ.μ. Παρασκευή, 4 Ιανουαρίου 2013
Θέμα: [GRASS-user] db loading error
Not exactly a grass question, but I figured you all might see what I’m doing wrong. I am trying load a postgis db that is connected to grass.
in order to do so, I’d like to automate the 100 or so files that need to be read into the db with a \copy process from a bash script. See below:
#!/bin/sh
for infile in /Volumes/disk7/b4warmed3/export/60min2/*.csv
do
cat infile | psql -h localhost dbname -c “\copy table1 FROM stdin with delimiter as ‘,’ NULL AS ‘NA’ CSV HEADER”
done
I’m getting an error about the name of the file I’m building to then copy from into the db.
Does this approach require that I create the file “infile” first? And if so, in what directory? Or does someone see some ridiculously stupid mistake I’m making?
Here’s the error:
[kirkw@truffula]bin$ ./b4warmed_loader
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
cat: infile: No such file or directory
Password:
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
On Saturday 05 of January 2013 06:53:42 Leonidas Liakos wrote:
Hi, the problem is here:cat infile
You need to write: cat $infile
Nice, you spotted that one Leonida 
Nikos
..