Hi there...I&#39;m new to Python scripting, with maybe 3 days under my belt thus far. Besides the occasional shell script, the last time I ever touched a programming language was probably at least 12 years ago, if that gives you any indication of my experience. :)<br>
<br>I don&#39;t know if this is the proper place to ask, but I&#39;ve run into the problem below.<br><br>Right now I&#39;m beginning to work within the Opsware Global Shell, which if you&#39;re unfamiliar with it, basically is exactly what it sounds like...the goal is to launch a script which changes directories to a list of servers, prints the server name, remotes into managed virtual servers, checks the date, and outputs this into a file. I do have a bash script as follows, which does the job:<br>
<br>#!/bin/bash<br>#<br># This script checks the dates on all managed systems.<br>OUTFILE=&quot;/home/ksarikhani/public/bin/timecheck.txt&quot;<br>rm -f $OUTFILE<br>cd &quot;/opsw/Server/@/&quot;<br>for SERVER_NAME in *<br>
do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ---- $SERVER_NAME<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo ---- $SERVER_NAME &gt;&gt; $OUTFILE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rosh -n $SERVER_NAME -l $LOGNAME \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;date&quot; &gt;&gt; $OUTFILE<br>done<br># Last line in date.sh.<br>
<br>Even though the above does what I need it to do, I&#39;d REALLY like to determine the equivalent in Python...I&#39;ve tried several different methods, but about as far as I get is printing the server name. This is what I&#39;ve cobbled together so far.<br>
<br>#!/usr/bin/python<br>import os, sys<br>sys.stdout = open(&#39;timecheck.txt&#39;,&#39;w&#39;)<br>for servername in os.listdir(&#39;/opsw/Server/@&#39;):<br>&nbsp;&nbsp;&nbsp; print &#39;---&#39;, servername<br>&nbsp;&nbsp;&nbsp; os.system(&#39;rosh -n $SERVER_NAME -l $LOGNAME&#39;)<br>
&nbsp;&nbsp;&nbsp; os.system(&#39;date&#39;)<br>sys.stdout.close()<br><br>The problem is this...for logging into systems via the global shell, one has to change directories to the one with the list of all managed servers (or specify the path for each one), and then launch a &quot;rosh -n &lt;hostname&gt; -l &lt;username&gt;&quot; to be able to get into it.<br>
<br>However, when I launch the script, what happens is the following message:<br><i>rosh: Username must be specified with -l or via path</i><br><br>And this is a continual loop that I can&#39;t break.<br><br>This is of course not a Python error, but as you might guess from looking at the script, the whole $SERVER_NAME piece is probably wrong. I thought maybe I could do something like this...<br>
<br><i>os.system(&#39;rosh -n&#39;, servername, &#39;-l $LOGNAME&#39;)</i><br><br>But of course os.system allows exactly one argument, and not three.<br><br>This is where I&#39;m stuck, and I&#39;ve been digging into the books and examples and forums and just not quite sure what to look for. I would have liked to have completed the script without asking for help, but nothing quite seems to fit what I&#39;m doing.<br>
<br>Any suggestions or guidance would be highly appreciated. Thanks!<br><br>K<br>