On Tue, May 1, 2012 at 4:54 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
GRASS 6.5.svn :~/grassdata > for file in "/home/rshepard/projects/data/*.kml"; do
v.in.ogr dsn="$file" out='$file'; done
ERROR: Unable to open data source
</home/rshepard/projects/washington/buckhorn/data/*.kml>
I think the quotes around "/home/rshepard/projects/data/*.kml" are
preventing the asterisk from being expanded as a wildcard. Try
removing them.
Cheers,
Tyler
On Tue, 1 May 2012, Tyler Smith wrote:
I think the quotes around "/home/rshepard/projects/data/*.kml" are
preventing the asterisk from being expanded as a wildcard. Try removing
them.
Tyler,
Good catch! That's part of the problem. Now GRASS cannot replace the
variable name, $file, with the actual file name:
WARNING: Illegal vector map name <$file>. Must start with a letter.
ERROR: Vector map name is not SQL compliant
It's probably referring to the output file name variable. Since there's no
reason to have the GRASS map name different from the DSN, I need to re-learn
BASH syntax for variable references.
Thanks,
Rich
On Tue, 1 May 2012, Imre Bornemisza wrote:
for file in $(ls -1 /home/rshepard/projects/data/*.kml); do
# $() - command substitution
v.in.ogr dsn="$file" out="$file"; done
# out='$file' - it means that you get a file with the name "dollarfile"
Imre,
I, too, was suspicious of the single quotes (may need to be backticks
instead). Replacing them with double quotes in the output file name still
throws an illegal file name error:
Illegal filename. Character </> not allowed.
ERROR: </home/rshepard/projects/data/wetlands.kml> is an illegal file name
Back to the ORA Bash book.
Rich
On Tue, May 1, 2012 at 5:22 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
On Tue, 1 May 2012, Tyler Smith wrote:
I think the quotes around "/home/rshepard/projects/data/*.kml" are
preventing the asterisk from being expanded as a wildcard. Try removing
them.
Tyler,
Good catch! That's part of the problem. Now GRASS cannot replace the
variable name, $file, with the actual file name:
WARNING: Illegal vector map name <$file>. Must start with a letter.
ERROR: Vector map name is not SQL compliant
It's probably referring to the output file name variable. Since there's no
reason to have the GRASS map name different from the DSN, I need to re-learn
BASH syntax for variable references.
Yes, you've wrapped the output file name in single quotes. That
prevents all expansions, wildcards and variables. I don't think you
need quotes at all.
Cheers,
Tyler
On Tue, 1 May 2012, Tyler Smith wrote:
Yes, you've wrapped the output file name in single quotes. That prevents
all expansions, wildcards and variables. I don't think you need quotes at
all.
Tyler,
Actually, the error references the DSN; that's the only string with a '/'
in it: Illegal filename. Character </> not allowed.
Thanks,
Rich
On Tue, May 1, 2012 at 5:38 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
On Tue, 1 May 2012, Tyler Smith wrote:
Yes, you've wrapped the output file name in single quotes. That prevents
all expansions, wildcards and variables. I don't think you need quotes at
all.
Tyler,
Actually, the error references the DSN; that's the only string with a '/'
in it: Illegal filename. Character </> not allowed.
Ah, I get it now. It's not really an illegal 'filename', in terms of
the operating system, it's an illegal mapname in terms of Grass. So
your Bash is now correct, it's your Grass that is broken. For the
output=$file part, try something like this: output=$(basename $file)
Tyler
On Tue, 1 May 2012, Tyler Smith wrote:
Ah, I get it now. It's not really an illegal 'filename', in terms of the
operating system, it's an illegal mapname in terms of Grass. So your Bash
is now correct, it's your Grass that is broken. For the output=$file part,
try something like this: output=$(basename $file)
Tyler,
I saw 'basename ' in the original thread but have not before seen it.
Thought it was a Windows reference. Now I know. I also need to strip off the
.kml extension since A) it's not part of a legal SQL table name and 2) it's
not needed.
Thanks,
Rich
On Tue, 1 May 2012, Rich Shepard wrote:
I also need to strip off the kml extension since A) it's not part of a
.legal SQL table name and 2) it's not needed.
For the record, and to close this thread, the working script is:
for file in $(ls -1 /home/rshepard/projects/data/*.kml); do v.in.ogr
dsn="$file" out=asename $file .kml; done
(All on one command line.)
Thanks, all!
Rich
On Tue, May 1, 2012 at 5:50 PM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
On Tue, 1 May 2012, Tyler Smith wrote:
Ah, I get it now. It's not really an illegal 'filename', in terms of the
operating system, it's an illegal mapname in terms of Grass. So your Bash
is now correct, it's your Grass that is broken. For the output=$file part,
try something like this: output=$(basename $file)
Tyler,
I saw 'basename ' in the original thread but have not before seen it.
Thought it was a Windows reference. Now I know. I also need to strip off the
.kml extension since A) it's not part of a legal SQL table name and 2) it's
not needed.
output=$(basename $file .kml)
Ty