Select to view content in your preferred language

sdetable -o create_view command

785
4
08-03-2011 10:08 AM
ToddMcNeil1
Emerging Contributor
I have batch files on a windows 2003 server that I would like to run on a unix server without making edits to the bat files.  The bat files have the "^" character to show a carriage return or new line.  For example,

sdetable -o create_view ^
-T PLACE_HOUSING_VW ^
-t PLACE,PLACE_HOUSING ^
-c PLACE.objectid,^
PLACE.GEOID,^
PLACE.STATE,^
PLACE.STUSAB,^
PLACE.PLACE,^
PLACE.NAME,^
B25002EST1,^
B25002EST2,^
B25002EST2_PCT,^
PLACE.shape ^
-w "PLACE.GEOID = PLACE_HOUSING.GEOID(+)" ^
-u ACS_5YR_2009 ^
-p ACS5YR2009

What would I replace the "^" symbol with to get these bat files to run as a unix shell script?  Right now, I have to take out all of the "^" characters and have the entire command on one line.  It works, but is extremely time consuming to fix and manage.  Any ideas?
0 Kudos
4 Replies
VinceAngelo
Esri Esteemed Contributor
The caret (^) is a DOS line continuation character. The Unix shell continuation is a
backslash (\). So to port your script you'd need to do a global replace. The following
would work:
 
 cat foo.bat | sed 's:\^$:\\:' > foo.sh


[Caret is regexp special character, as is backslash, so they need to be escaped;
the dollar sign matches end-of-line, so this won't alter non-terminal carets the
way "tr '^' '\\'" would.]

As always with Unix, there's many ways to do this -- You could also use 'vi' remove all
the terminal carets (:1,$s/\^$//) and concatenate the lines with auto-repeat of "J".

- V
0 Kudos
MahindaAbeykoon
Occasional Contributor
Vince,

I was using your instructions to create a SDE View from one to many relationship Feature classes posted on http://forums.esri.com/Thread.asp?c=158&f=2284&t=279941.

It worked well. I just want to thank you and ESRI forthis help, saving our time and hardships.

Mahinda
0 Kudos
ToddMcNeil1
Emerging Contributor
Vince,

I swapped out my "^" with the "\" and the view scripts worked like a charm.  So, thank you very much for the tip.

One more thing, can you create a shell script to run multiple shell scripts and log each one.  We have been doing this with a  bat file that will run each create view bat file and log each one.  It worked well and I was wondering if you could do the same thing in UNIX.  I just don't know the language.

Thanks,
Todd
0 Kudos
VinceAngelo
Esri Esteemed Contributor
There are four or five different Unix shells, and all of them have more capability than DOS
(it's not even close). DOS borrowed Borne shell's redirection operators, so a script to run
all scripts in a directory, logging both stdout and stderr to different timestamped files in
Bourne would look like:

 
#!/bin/sh
# RunAll.sh - Execute all *.sh scripts in current directory (except this one)
d=`date "+%Y%m%d"`
for s in `ls *.sh`
do
        test `basename $s` = `basename $0` && continue
        echo "Executing script '$s'..."
        log1=`basename $s .sh`-${d}.log
        log2=`basename $s .sh`-${d}.err
        ./$s > $log1 2> $log2
done


There are any number of good books and websites for shell tyros (though my favorite
book is no longer in print).

- V

PS: To put both STDOUT and STDERR in the same file, use "./$s > $log1 2>&1"
0 Kudos