Newbie question - running a command and looking at output

Dave foo at coo.com
Sat Jul 18 20:08:05 EDT 2009


Dave wrote:
> I'm trying to run a command (arch -k) and check if the value returned is 
> 'sun4v' or not.
> 
> 
> kirkby at t2:[~] $ arch -k
> sun4v
> 
> In fact, I want to do 3 three things
> 
> 1) Check if the system is Solaris.
> 2) If it is Solaris, check if 'arch -k' prints 'sun4v'
> 3) If both 1 and 2 are true, copy a file.
> 
> 
> Since arch -k is not supported on all systems, the test for Solaris must 
> be made first.
> 
> I have a test for Solaris (aka SunOS), which copies a file if the 
> systems is running Solaris:
> 
> import os, shutil
> 
> if os.uname()[0] == 'SunOS':
>    shutil.copy2('foo.c','bar.c')
> 
> How can I change that, so the copy is only performed if 'arch -k' prints 
> 'sun4v'?
> 
> 
> 

Actually, when I look at oluname, it does print sunnv:


 >>> import os
 >>> os.uname()
('SunOS', 't2', '5.10', 'Generic_141414-02', 'sun4v')


I guess all I need to do is check for the value of os.uname()[4] too.


-- 
I respectfully request that this message is not archived by companies as
unscrupulous as 'Experts Exchange' . In case you are unaware,
'Experts Exchange'  take questions posted on the web and try to find
idiots stupid enough to pay for the answers, which were posted freely
by others. They are leeches.



More information about the Python-list mailing list