<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div>to add a delay, use sleep n where n is a number seconds to pause. You can use different units from seconds. Man sleep will give a bit more detail.<br>
<br></div>For fun, you can do a loop in the master script that that just calls the launch script (same one) over and over and that pulls a conf string based on the param passed <br><br></div>master:<br><br></div>#!/bin/bash  (I always spec /bin/bash so it won&#39;t fubar under a reset link to csh or &lt;shudder&gt;zsh)<br>
</div># master script<br></div><div>MINNING=&lt;path to mining script&gt;  (this is chmod +x)<br></div>miners=4<br></div>for i in $(seq 1 ${miners})<br></div>do <br>  ${MINNING} ${i}<br></div>done<br></div><div>tail -f &lt;path to logs&gt;/miner*.log<br>
</div><div><br><br>---------------------------<br></div><br><br>The MINNING script is generically:<br></div>#!/bin/bash<br></div># this runs the actual minning process<br><br></div>which_one=$1<br><br></div>case $which_one in<br>
</div>  1)       graphics_param=&#39;string of crap for card 1&#39;<br><div><div><div><div><div><div><div>            log_file=&#39;path to output log/miner&#39;${which_one}&#39;.log&#39;<br>            ;;<br></div><div>  2)       graphics_param=&quot;second string of graphics crap&#39;<br>
</div><div>            log_file.....<br>            ;;<br>...<br></div><div>esac<br><br></div><div># Now run the script with all the params<br><br></div><div>&lt;miner binary name&gt; ${graphics_param} ${log_file} &amp;<br>
<br></div><div>return 0<br></div><div><br>------------------------------<br><br></div><div>So if you get more graphics cards, edit the script and add a new case line and edit the master and up the counter.<br></div><div><br>
</div></div></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 17, 2013 at 9:35 PM, Ron Frazier (ALE) <span dir="ltr">&lt;<a href="mailto:atllinuxenthinfo@techstarship.com" target="_blank">atllinuxenthinfo@techstarship.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>


  

<div text="#000000" bgcolor="#ffffff">
Scott,<br>
<br>
I want to thank you for the very detailed response you gave.  This gave
me enough information to solve the problem.  I thought I&#39;d share the
solution in case others might benefit from it.  What I think is useful,
is the way I&#39;ve stacked multiple scripts together and attached them to
an icon.  This can be handy whether you&#39;re mining or not.<br>
<br>
Here is a simplified version of the MINER1 script that runs the
specific process for graphic card 1.  There will be a MINER2, 3, and 4.<br>
<br>
#!/bin/bash -eu<br>
# script to start litecoin mining on the first graphic card<br>
cd ~/cgminer<br>
export -task-specific-stuff-<br>
./cgminer -lots-of-special-parameters-for-gpu1-only-<br>
echo &quot;Press enter to continue.&quot;<br>
read junk<br>
<br>
I got the -eu part on the bash line from a book, which adds in some
special error checking for bash.<br>
The last two lines force the script to pause before closing its window
until you press enter.<br>
<br>
For MINER2, 3, and 4, I&#39;ve temporarily commented out all lines except
the last two, so I can use them for testing.<br>
<br>
Here is the START-MINERS script, which starts each individual miner
script, in its own separate window, with it&#39;s own separate geometry and
title.<br>
<br>
#!/bin/bash -eu<br>
# program to start all mining scripts<br>
cd ~/mining-scripts<br>
# commands to start the first miner<br>
mate-terminal --geometry=70x4+1800+100 -t &quot;Miner 1&quot; -e ./miner1 &amp;<br>
# commands to start the second miner<br>
mate-terminal --geometry=70x4+1800+250 -t &quot;Miner 2&quot; -e ./miner2 &amp;<br>
# commands to start the third miner<br>
mate-terminal --geometry=70x4+1800+400 -t &quot;Miner 3&quot; -e ./miner3 &amp;<br>
# commands to start the fourth miner<br>
mate-terminal --geometry=70x4+1800+550 -t &quot;Miner 4&quot; -e ./miner4 &amp;<br>
echo &quot;Press enter to continue.&quot;<br>
read junk<br>
<br>
I have to use mate-terminal to activate Mint&#39;s terminal emulator.  The
--geometry option (mentioned by both you and Brian) sets the window
size for each MINERx script as well as a location so they all stack up
on the right of my monitor.  The -t option specifies a unique title for
each window.  Each MINERx program is started with the &quot;&amp;&quot; command
(also mentioned by you and Brian) so the master script keeps on going
without waiting.  For some reason, I had to put the read command at the
end of the START-MINERS script or the sub scripts never kick off.  I
have no idea why.<br>
<br>
I&#39;d rather have a delay in the START-MINERS script so it would
terminate without me pressing a key.  I haven&#39;t found out how to do
that.<br>
<br>
Finally, here&#39;s how I created an icon in GNOME to kick off the whole
enchilada.<br>
<br>
Right click on the desktop, click create launcher, select type:
application, name: Start Miners, command: mate-terminal -e
/home/ron/mining-scripts/start-miners, click OK.<br>
<br>
Now, upon clicking this icon, it starts the start-miners script, which
in turn starts MINER1, 2, 3, and 4, which in turn post 4 terminal
windows on the screen and run the processes I want them to.<br>
<br>
Very cool.<br>
<br>
Thanks again for the help.<br>
<br>
Sincerely,<br>
<br>
Ron<div><div class="h5"><br>
<br>
<br>
On 4/17/2013 3:36 PM, Scott Plante wrote:
<blockquote type="cite">
  
  <div style="font-size:12pt;font-family:arial,helvetica,sans-serif">(answers
inline)<br>
  <div>
  <div><br>
  </div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; So, my first
question is how do I set up a basic script file </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; with these
commands in it.  I can fill in all the details later.</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; cd ~/cgminer</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; export .....</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; ./cgminer .....</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">Yes, you can do that.
You&#39;ll need to set the execute bit using &quot;chmod +x miner1&quot; or &quot;chmod
755 miner1&quot; or similar.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">Usually you&#39;ll want to
put this as the first line of your script:</font></div>
  <div><font face="Helvetica, Arial, sans-serif">#!/bin/bash</font></div>
  <div><font face="Helvetica, Arial, sans-serif">But it&#39;s not strictly
necessary. It comes into play usually when you&#39;re in one shell and the
script is written for another, but it&#39;s a good habit to get into.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; Also, how do I
put comments in the file?</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">bash and most Linux
shells use # to start comments. Anything after the pound on a line is a
comment.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; Now, as I said,
the command for each graphics card </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; is unique.  So, I
need to set up a MINER2, MINER3, </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; and MINER4
scripts, which are customized for the </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; individual
graphics cards.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">Well, you could make
one script that takes a parameter and use something like:</font></div>
  <div><font face="Helvetica, Arial, sans-serif">if [ &quot;$1&quot; = 1 ]; then</font></div>
  <div><font face="Helvetica, Arial, sans-serif">  #miner1 specific
commands...</font></div>
  <div><font face="Helvetica, Arial, sans-serif">elif [ &quot;$1&quot; = 2 ]; then</font></div>
  <div><font face="Helvetica, Arial, sans-serif">  #miner2 specific
commands...</font></div>
  <div><font face="Helvetica, Arial, sans-serif">#and so on...</font></div>
  <div><font face="Helvetica, Arial, sans-serif">elif [ &quot;$1&quot; = --all ]</font></div>
  <div><font face="Helvetica, Arial, sans-serif">  #I&#39;ll come back to
this</font></div>
  <div><font face="Helvetica, Arial, sans-serif">else</font></div>
  <div><font face="Helvetica, Arial, sans-serif">  echo &quot;USAGE: $0
[--all|miner-num]&quot; 1&gt;&amp;2; exit 1</font></div>
  <div><font face="Helvetica, Arial, sans-serif">fi</font></div>
  <div><br>
  </div>
  <div><font face="Helvetica, Arial, sans-serif">You could also use
&quot;case&quot; instead of if/elif/else/fi and that might be cleaner. As always,
there&#39;s more than one way to skin the cat.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; Finally, I want
to create a master script to start all the other </font></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">4.  Here&#39;s the trick.  I want the
master script to start each of </font></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">the sub scripts in its own window
and continue executing </font></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">commands in the master script.  I
don&#39;t want the master </font></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">script to hang waiting for MINER1
to exit before executing</font></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">MINER2, and so forth.</font></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt; </span></div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">Let&#39;s say that the master script
is called START-MINERS.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">Well, do you really
need separate windows or do you just need parallel execution?
Generally, you can use the ampersand (&amp;) at the end of a line to
run that command in the background. If the miner commands have output
you want to view on the screen, you can start an xterm to open a window
for each one. I use kde, so I tend to use konsole but for this purpose
xterm will work or you can check the options for whatever terminal
window you like to use. In the above script under &quot;--all&quot; where I said
I&#39;d come back to it, you could put:</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">for miner in 1 2 3 4</font></div>
  <div><font face="Helvetica, Arial, sans-serif">do</font></div>
  <div><font face="Helvetica, Arial, sans-serif">  xterm -e $0 $miner
&amp;</font></div>
  <div><font face="Helvetica, Arial, sans-serif">done </font></div>
  <div><br>
  </div>
  <div>dollar-zero is the current script so you&#39;re re-running the
current script once each for 1, 2, 3, 4. Although since it&#39;s just 4 you
might just repeat the command four times instead. Or go the other way
and have a config file that defines each miner instance, but that seems
like a down-the-road enhancement. </div>
  <div><br>
  </div>
  <div><span style="font-family:Helvetica,Arial,sans-serif">&gt;</span><span style="font-family:Helvetica,Arial,sans-serif"> </span><font face="Helvetica, Arial, sans-serif">Finally, I want to kick off the
whole thing from one icon on</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; the desktop which
triggers START-MINERS which triggers</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; MINER1, 2, 3, and
4.  I don&#39;t care if the master script has a </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; terminal window
left on the screen or not when it&#39;s done.  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; However, when
it&#39;s finished, there should be 4 active terminal </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; windows on the
screen mining on 4 separate graphics cards.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">In kde, you can
right-click on the desktop, select &quot;Create new-&gt;Link to application&quot;
and then fill in the boxes. I imagine you can do something similar in
Gnome.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; Even better, I&#39;d
like the windows to automatically size themselves </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; to a certain size
and stack up all in a column on the monitor.  Better</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; still, would be
to have the whole thing auto start when booting.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">xterm and most X
Windows programs accept certain standard options, which you can see by
running &quot;man X&quot;. In this case you can specify the size and location
with &quot;-geometry&quot;. So for example:</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">xterm -geometry
80x30+10+10 -e $0 $miner &amp;</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">as the xterm command.
You could just specify 4 (or however miner instances you have) separate
xterm commands instead of the &quot;for&quot; loop, or you could also do math in
the shell based on the miner number. That might be more trouble than
it&#39;s worth, though. </font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">As to starting
automatically on boot, you have the issue of needing to be logged in to
start the xterms. You&#39;d probably want to send the output to a log file
for the actual miner commands, then when you login you could have a
command that starts the xterms with &quot;tail -f logfile&quot; instead of
actually running the miners directly. In this scenario you&#39;d create an
/etc/init.d script to start the actual miner processes. You probably
want to see where you can get with the above before jumping into that.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; If you can help
me with all or part of this puzzle,</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; I&#39;d greatly
appreciate it.  Thanks in advance.</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt;</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; Sincerely,</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt;</font></div>
  <div><font face="Helvetica, Arial, sans-serif">&gt; Ron</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">Well, that should get
you started anyway. I typed these commands mostly off the top of my
head, so there may be some &quot;miner&quot; errors (ha ha). You will find the
docs for the if/then/elif/else/fi and case/esac under &quot;man bash&quot;. You
can man xterm for details on other options. Reply with more specific
questions as you get into it, if you need to.</font></div>
  <div><font face="Helvetica, Arial, sans-serif"><br>
  </font></div>
  <div><font face="Helvetica, Arial, sans-serif">Scott</font></div>
  </div>
  <div><br>
  </div>
  <br>
  <br>
  <div><span name="x"></span>-- <br>
Scott Plante, CTO<br>
Insight Systems, Inc.<br>
<a href="tel:%28%2B1%29%20404%20873%200058%20x104" value="+14048730058" target="_blank">(+1) 404 873 0058 x104</a><br>
<a href="mailto:splante@insightsys.com" target="_blank">splante@insightsys.com</a><br>
<a href="http://zyross.com" target="_blank">http://zyross.com</a><br>
  <br>
  <span name="x"></span></div>
  </div>
</blockquote>
<br>
<br>
</div></div><div class="im"><pre cols="72">-- 

(PS - If you email me and don&#39;t get a quick response, you might want to
call on the phone.  I get about 300 emails per day from alternate energy
mailing lists and such.  I don&#39;t always see new email messages very quickly.)

Ron Frazier
<a href="tel:770-205-9422" value="+17702059422" target="_blank">770-205-9422</a> (O)   Leave a message.
linuxdude AT <a href="http://techstarship.com" target="_blank">techstarship.com</a> 
Litecoin: LZzAJu9rZEWzALxDhAHnWLRvybVAVgwTh3
Bitcoin: 15s3aLVsxm8EuQvT8gUDw3RWqvuY9hPGUU
</pre>
</div></div>

<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>-- <br>James P. Kinney III<br><i><i><i><i><br></i></i></i></i>Every time you stop a school, you will have to build a jail. What you 
        gain at one end you lose at the other. It&#39;s like feeding a dog on his 
        own tail. It won&#39;t fatten the dog.<br>

        - Speech 11/23/1900 Mark Twain<br><i><i><i><i><br><a href="http://electjimkinney.org" target="_blank">http://electjimkinney.org</a><br><a href="http://heretothereideas.blogspot.com/" target="_blank">http://heretothereideas.blogspot.com/</a><br>
</i></i></i></i>
</div>