<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On 3-Aug-06, at 12:57, Sampson, David wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">  <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">Scott,</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV> <DIV dir="ltr" align="left"><FONT class="Apple-style-span" color="#0000FF" face="Arial" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">BTW I remember Markus showing us a way to save commands you type to the GRASS CLI into a script (think is was X.save where X=something).. this is good if you want to perform it once in geenral and then edit the script for variations. Couldn't find it off hand in the docs.</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN><BR></DIV></BLOCKQUOTE><DIV>If you're using the command line, then you're just using a UNIX shell, customized to be able to run the GRASS modules.  UNIX shells tend to have their own history mechanisms, so we just take advantage of that.  If I remember correctly, the GRASS startup fires up the bash shell, and manipulates this to store the history during GRASS sessions into the mapset directory (in a .bash_history file).  So you can actually go find that file (it's just a text file) and look in it to see what has been entered - you can also use the bash history command - try typing that in from the GRASS prompt, and you should see a list of everything you've been doing.  You can also redirect it to a file.  Lots of possibilities - not sure which way was shown to you, but just looking in $MAPSET/.bash_history and extracting the part you want is simple enough.</DIV><BR><BLOCKQUOTE type="cite"><DIV dir="ltr" align="left"> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">I'd be interested to know if you could set and use variables in the approach we used bellow. I never tried.  but if you could say use output=$OUTMAP and input=$INMAP and then you can loop for a series of maps. and the input and output are auto generated based on the basefile name.</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">Can someone provide a sample snippet of how this might look?</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">Would the for loop be part of the said script, or would you call one script from another passing variables?</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">This might be good if it is a repeated process you will use ALOT... a type of mild automation.</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN><BR></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Definitely.  I see now that at least one example is already posted.  You may be interested in the BASH scripting guide at <A href="http://www.tldp.org/LDP/abs/html/">http://www.tldp.org/LDP/abs/html/</A></DIV><BR><BLOCKQUOTE type="cite"><DIV dir="ltr" align="left"> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">I notice that in grass 6.1 there is lots of information in the OUTPUT window of what is passed from the command... can you capture this?.. I have not tried any of the icons....  if so then this is another way to maybe build your script.  I'm likin 6.1 more and more</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>There is a way to get at it in the GUI I'm told, but I still keep using the command line myself...</DIV><BR><BLOCKQUOTE type="cite"> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2">Just some thoughts.</FONT></SPAN></DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV> <DIV dir="ltr" align="left"><SPAN class="559404916-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV><BR> <DIV class="OutlookMessageHeader" lang="en-us" dir="ltr" align="left"> <HR tabindex="-1"> <FONT face="Tahoma" size="2"><B>From:</B> Scott Mitchell [<A href="mailto:smitch@mac.com">mailto:smitch@mac.com</A>] <BR><B>Sent:</B> August 3, 2006 12:47<BR><B>To:</B> Sampson, David<BR><B>Cc:</B> Tiago Salgueiro; <A href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it</A><BR><B>Subject:</B> Re: [GRASS-user] run commands sequentially - help please<BR></FONT><BR></DIV> <DIV></DIV> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>A few elaborations that might help unix-newbies:</DIV><BR> <DIV> <DIV>On 3-Aug-06, at 12:25, Sampson, David wrote:</DIV><BR class="Apple-interchange-newline"> <BLOCKQUOTE type="cite">  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">Dirty approach,</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">I used this approach when doing mass imports of files and   only had slight variations.</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">under linux (shoudl work too in cygwin, dos batch would   achieve the same thing)</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">I created a script file (executable text Basicaly) that   for you would look like</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"># for a script named runme.sh</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">#(what ever header you need for your   shell)</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"></SPAN><SPAN class="468230416-03082006">#!/bin/sh</SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN><BR></DIV></BLOCKQUOTE> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>Putting $!/bin/sh at the top of a script will ensure that the file gets interpreted by whatever the default shell is on the system.  Forcing other shells is also possible here, but using just "sh" means you get the default (i.e. as opposed to bash, csh, tcsh, ksh, etc etc).</DIV><BR> <BLOCKQUOTE type="cite">  <DIV dir="ltr" align="left"> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">v.in.asci (string of settings);</FONT></SPAN></DIV></BLOCKQUOTE> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>note that should be ascii with two i's</DIV><BR> <BLOCKQUOTE type="cite">  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">g.region (string of settings);</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">v.surf.rst (string of settings);</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">nviz (string of settings);</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">#end of script</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">then at the $prompt  you need to make the file   executable</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">$chmod 777 runme.sh</FONT></SPAN></DIV></BLOCKQUOTE> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>Note this makes the file readable, writeable and executable to everyone on the system.  If this is just your own private linux or windows box, you probably don't care, but if someone is doing this on a multi-user system, you might not want other people to be able to edit your files.  Using chmod 755 would make it readable and executable to anyone, but only writeable to you, the owner of the file.  An alternative, more user-friendly syntax is</DIV> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>chmod u+x runme.sh</DIV> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>which simply says add the execute permission ("+x") for the User ("u") that owns runme.sh</DIV><BR> <BLOCKQUOTE type="cite">  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">then at the $prompt inside a GRASS session you can run   the file</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">$./runme.sh</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">boom!</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">notice in the script that each line ends in a ;   (semi-colon) this separates each command</FONT></SPAN></DIV></BLOCKQUOTE> <DIV><BR class="khtml-block-placeholder"></DIV> <DIV>I don't think you need that.  It's C syntax to do that, not needed in a shell script unless you're concatenating multiple commands on to a single line.</DIV><BR> <BLOCKQUOTE type="cite">  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">Note also that sometimes options need to be in   quotes</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">eg</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">v.in.ascii option1="settings string that may contain   escape characters or spaces";</FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2">Alternatively you can capture what you enter at the CLI   using </FONT></SPAN></DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><SPAN class="468230416-03082006"><FONT face="Arial" color="#0000ff" size="2"></FONT></SPAN> </DIV>  <DIV dir="ltr" align="left"><FONT face="Arial" color="#0000ff" size="2"></FONT><BR> </DIV>  <DIV class="OutlookMessageHeader" lang="en-us" dir="ltr" align="left">  <HR tabindex="-1">  <FONT face="Tahoma" size="2"><B>From:</B> <A href="mailto:grassuser-bounces@grass.itc.it">grassuser-bounces@grass.itc.it</A> [<A href="mailto:grassuser-bounces@grass.itc.it">mailto:grassuser-bounces@grass.itc.it</A>]   <B>On Behalf Of </B>Tiago Salgueiro<BR><B>Sent:</B> August 3, 2006   11:24<BR><B>To:</B> <A href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it</A><BR><B>Subject:</B>   [GRASS-user] run commands sequentially - help please<BR></FONT><BR></DIV>  <DIV></DIV>  <DIV class="Section1">  <H3><A name="_Toc119731566"><U><FONT face="Times New Roman" size="3"><SPAN style="FONT-SIZE: 12pt">Hi all</SPAN></FONT></U></A><SPAN style="TEXT-DECORATION: none">,</SPAN></H3>  <DIV><FONT face="Arial" size="2"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV><P class="MsoNormal"><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">First of all you should know that   I’m a beginner using GRASS.</SPAN></FONT></P>  <DIV><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV><P class="MsoNormal"><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I want to create a 3D map from a   text file with coordinates. I think the commands I will need are the   following:</SPAN></FONT></P>  <H3><FONT face="Times New Roman" size="3"><SPAN lang="EN-GB" style="FONT-SIZE: 12pt; TEXT-DECORATION: none"></SPAN></FONT> </H3>  <H3><FONT face="Times New Roman" size="3"><SPAN lang="EN-GB" style="FONT-SIZE: 12pt; TEXT-DECORATION: none">1 -   v.in.ascii</SPAN></FONT></H3>  <H3><A name="_Toc119731567"><FONT face="Times New Roman" size="3"><SPAN lang="EN-GB" style="FONT-SIZE: 12pt; TEXT-DECORATION: none">2 -   g.region</SPAN></FONT></A></H3>  <H3><A name="_Toc119731569"><FONT face="Times New Roman" size="3"><SPAN lang="EN-GB" style="FONT-SIZE: 12pt; TEXT-DECORATION: none">3 -   v.surf.rst</SPAN></FONT></A></H3>  <H3><A name="_Toc119731571"><FONT face="Times New Roman" size="3"><SPAN lang="EN-GB" style="FONT-SIZE: 12pt; TEXT-DECORATION: none">4 – nviz</SPAN></FONT></A></H3>  <DIV><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV><P class="MsoNormal"><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">But I don’t want to write the   commands every time I want to see a map. So I desire to do this sequentially.   How can I do that? This way I’ll only need to run one command and the map   happens.</SPAN></FONT></P>  <DIV><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV><P class="MsoNormal"><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Thanks for your   help.</SPAN></FONT></P>  <DIV><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV>  <DIV><FONT face="Arial" size="2"><SPAN lang="EN-GB" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV><P class="MsoNormal"><B><U><FONT face="Verdana" color="navy" size="2"><SPAN lang="EN-GB" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana">Cumprimentos/Best   Regards,</SPAN></FONT></U></B></P><P class="MsoNormal"><B><FONT face="Verdana" color="navy" size="3"><SPAN lang="EN-GB" style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: navy; FONT-FAMILY: Verdana"></SPAN></FONT></B> </P><P class="MsoNormal"><B><FONT face="Verdana" color="navy" size="2"><SPAN lang="EN-GB" style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Verdana">Tiago   Salgueiro</SPAN></FONT></B></P>  <DIV><FONT face="Times New Roman" size="3"><SPAN lang="EN-GB" style="FONT-SIZE: 12pt"></SPAN></FONT><BR class="khtml-block-placeholder"> </DIV></DIV>  <DIV style="MARGIN: 0px">_______________________________________________</DIV>  <DIV style="MARGIN: 0px">grassuser mailing list</DIV>  <DIV style="MARGIN: 0px"><A href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it</A></DIV>  <DIV style="MARGIN: 0px"><A href="http://grass.itc.it/mailman/listinfo/grassuser">http://grass.itc.it/mailman/listinfo/grassuser</A></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></DIV><BR></BODY></HTML>