Поправил на более универсальный вариант, для линукс и виндуз
Sub Main
user=createUnoService("com.sun.star.util.PathSubstitution").getSubstituteVariableValue("$(user)")
mkdir ConvertFromURL(user & "/Scripts/python")
pscript=""
sep=getPathSeparator()
for each c in split(ConvertFromURL(user & "/Scripts/python"),sep)
pscript=pscript & ".." & getPathSeparator()
next
if sep="\" then
home=environ("USERPROFILE")
else
home=environ("HOME")
end if
tmp=home & sep & ".tmp" & sep
mkdir tmp
script=tmp & "pyshell.py"
f=FreeFile
open script for output as #f
print #f, "import os" & chr(10) & "def shell(x):return """".join(os.popen(x).readlines())"
close #f
drive=split(script,sep)(0)
if len(drive)=2 and right(drive,1)=":" then script=mid(script,3)
script=replace(pscript & script,sep,"/")
script = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory").createScriptProvider("")._
getScript("vnd.sun.star.script:" & script & "$shell?language=Python&location=user")
msgbox script.invoke(array("dir """ & replace(home,"/",sep) & """"), array(), array())
End Sub