Ahh, Win-BASH cool!!! On Tue, Jul 15, 2008 at 10:41 AM, Aquil H. Abdullah < [EMAIL PROTECTED]> wrote:
> Ack, .bat files! Yes, you are correct Windows does not ship with Python, > and there are ways to get bash (cygwin) on your Windoze system. I am > leaning towards a solution similar to your second suggestion as it will keep > me from having to distribute .bat files for one platform and .sh files for > another. Thank you for all of your suggestions. > > > On Mon, Jul 14, 2008 at 8:39 PM, Derek Martin <[EMAIL PROTECTED]> wrote: > >> On Mon, Jul 14, 2008 at 05:40:43PM -0400, Aquil H. Abdullah wrote: >> > You've hit the proverbial nail with the hammer. The problem is that my >> > application needs to run under both the Linux and Windows OSs, so while >> I >> > would love to use a nice sh, csh, or bash shell script. My hands are >> tied >> > because Windows does not provide such wonderful shells. >> >> *Provides*, no... neither does it provide Python, for what that's >> worth. But you can certainly get it (bash): >> >> http://win-bash.sourceforge.net/ >> >> I suppose it's not worth installing just for this purpose though... >> But you can provide with your application a DoS batch file that does >> exactly the same thing (in addition to a shell script). The user >> would quite intuitively use whichever were appropriate, or follow your >> provided directions otherwise. Or, the equivalent in (hopefully >> OS-agnostic) Python: >> >> import os, sys >> >> # I believe this gets the name of the root in all major OSes >> def root_dir(path): >> if os.path.dirname(path) == path: >> return path >> return (root_dir(os.path.dirname(path))) >> >> appname = <name of your python script> >> root = root_dir(os.getcwd()) >> install_path = os.path.join(root, "usr") >> bin_path = os.path.join(install_path, "bin") >> os.environ["PATH"] = bin_path + os.pathsep + os.environ["PATH"] >> python_path = os.path.join(bin_path, "python") >> args = sys.argv[1:] >> args.insert(0, os.path.join(bin_path, appname)) >> args.insert(0, python_path) >> args.insert(0, python_path) >> os.execv(python_path, args) >> >> >> >> > > > -- > Aquil H. Abdullah > [EMAIL PROTECTED] > -- Aquil H. Abdullah [EMAIL PROTECTED]
-- http://mail.python.org/mailman/listinfo/python-list