Newbie question - running a command and looking at output

D

Dave

I'm trying to run a command (arch -k) and check if the value returned is
'sun4v' or not.


kirkby@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'?



--
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.
 
D

Dave

Dave said:
I'm trying to run a command (arch -k) and check if the value returned is
'sun4v' or not.


kirkby@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:

('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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top