I have an old script which I use to run in Ubuntu.
Now, I have a Mac and want to reuse the script.
Does anyone know what would be equivalent of the following commands in Mac OS?
def runCmd(cmd):
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
result=p.stdout.readlines()
s=result[0].split()[0]
return s
def getKernelVer():
cmd="uname -r| cut --delim=\'.\' -f1-2"
return runCmd(cmd)
def getUbuntuVer():
cmd="lsb_release -a | grep Release | cut -f 2"
return runCmd(cmd)
Thanks
uname -rworks identically under Darwin. The kernel version isn’t something that most people talk or care about, but it’s there. Only gotcha is thatcutdoesn’t support the--delimlong option, so, try this instead:Kernel versioning is quite different for Darwin than for Linux, though, so the purpose of running
cuthere is unclear. (In fact, it’s not quite clear on Linux either, as the versioning scheme changed significantly with the release 3.0.)To get the current version of Mac OS (roughly equivalent to the “release” you’re getting for Ubuntu), you can use the command: