<br><br><div class="gmail_quote">On 23 September 2011 15:38, Dave Hanson <span dir="ltr"><<a href="mailto:dave@hansonforensics.co.uk">dave@hansonforensics.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>Hello Everyone,</div><div><br></div>I have scoured the web and can only find half baked answers to my question - I'm hoping someone here can help?<div><br></div><div>I know that Python is classed as a portable programming language (it will run on anything) So I'm wondering how do you code in such a way that your script can just be 'ported' over to another OS?</div>

<div><br></div><div>I have this code to locate the Firefox directory:</div><div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">

from subprocess import Popen, PIPE<br>li = Popen(['find', '/', '-iname', '*.default'], stdout=PIPE).stdout.read().split('\n')<br>flag = 1<br>for item in li:<br>    if item.find('firefox') != -1:<br>

        print >>outfile, "Firefox Directory: ", item<br>        flag = 0<br>        break</blockquote></div><div><br></div><div><div>It works fine on my Ubuntu machine, It won't run on a Windows machine (haven't tested) I think because I'm calling the unix version of find and also my path is /, obviously this would be c: in windows.</div>

<div><br></div><div>I want to search the entire disk of any OS to find the Firefox cache directory. Is it even possible to do this? I don't particularly need the code to do it (I don't mind if you want to share though!) What I'm really after is - Am I wasting my time even trying?</div>

<div></div></div></blockquote><div><br></div><div>Simple answer is that there probably isn't anything that's universal so it would be easier to detect the OS using sys.platform and write specific code for each platform.</div>
<div><br></div><div>s/</div><div> </div></div>-- <br>Twitter: @sfgreenwood<div>"Is this your sanderling?"<br></div><br>