1

In writing an install script, I quickly found that I'd have cross-platform issues, and bash scripts are hard to maintain. I decided to look for a cleaner solution that's more cross-platform.

The goal is to have an intelligent script sniff out components of the user's system and have as little user interaction as possible. That being stated, I thought about these languages:

  • Python- cross-platform, and many other programs rely on it, so it may already be present
  • Javascript- nodejs is required by part of my application, but it's a little clunky for exec calls

Are there any languages that would be a better fit for this application?

Requirements:

  • Available on all platforms
    • May be distributed as part of my application if small enough
    • Little to no version variation, so Ruby is out
    • *nix only for now, but eventually will be run on Windows
  • Maintainable
    • Clear syntax (Perl is out)
    • Modular (if I sniff the OS, I can include separate OS-specific code)
  • Capable of downloading files (unmet dependencies)
  • Capable of relatively complex scripting tasks
    • Testing for used HTTP ports
    • Reading and parsing files for configuration data
    • Checking for permissions and changing directories of insufficient privileges
  • Open source
beatgammit
  • 19,817
  • 19
  • 86
  • 129

2 Answers2

2

Python can do all of those things:

  • Available on all platforms (Mac, Linux, Windows, and more)
    • May be distributed as part of my application if small enough (You can make binaries with cx_freeze, if needed)
    • Little to no version variation, so Ruby is out (Python is pretty static when it comes to version changes)
    • *nix only for now, but eventually will be run on Windows (It comes pre-installed on Mac, and ships with just about any Linux distro. Binaries don't need the interpreter to run)
  • Maintainable
    • Clear syntax (Perl is out) (Python is very easy to read, but that's up to you to decide)
    • Modular (if I sniff the OS, I can include separate OS-specific code) (Modules are just files in Python)
  • Capable of downloading files (unmet dependencies) (Urllib2 takes care of that, and it's pre-installed)
  • Open source (Yep)
Blender
  • 289,723
  • 53
  • 439
  • 496
  • I just started learning Python earlier this week. How simple is it to call native command-line applications (grep, sed, cat, etc)? – beatgammit Aug 07 '11 at 05:11
  • It's a bit hard to capture output of commands (not hard, but more than one line of code), so Python has most of those commands implemented one way or another. `cat` would be `open('file.txt', 'r').read()`. You'll find it awkward that it's not as easy as you'd like to call system commands (it's just `import os` and `os.system('foo')`, btw), but in the long run, native solutions are a lot easier to work with. **TL;DR: you'll pick that stuff up as you learn more about Python** – Blender Aug 07 '11 at 05:20
  • Ironically, the reason I considered Python in the first place is because I started some work in Blender. Thanks for all the help! – beatgammit Aug 07 '11 at 05:24
  • Me too ;) It's a nice language, but I never really used it for Blender much. Maybe once for a 3D plotter, but that's about it. You'll love the way it doesn't break when you switch data types. – Blender Aug 07 '11 at 05:29
  • Like Javascript. It's nice to be able to assign stuff to a variable, instead of having to worry about types. I think Python my be the tool for the job, but I'll leave this open for a little bit just in case someone comes out with something better. – beatgammit Aug 07 '11 at 05:33
  • Never used Python for this purpose myself, so I think there should be competitors. – Blender Aug 07 '11 at 05:36
0

Ant will do what you need. It is OS independent and will allow compiles and installs.

Joe Zitzelberger
  • 4,238
  • 2
  • 28
  • 42
  • I'm not too familiar with it. Does it allow relatively complex scripting (like downloading stuff from the web, scanning for HTTP ports, generating files based on user input)? – beatgammit Aug 07 '11 at 05:07