1

I'm really feeling stupid but I don't find the right search keywords to get something usefull out of google.

The problem: We are developing symfony1 and symfony2 applications (php). We are developing on windows machines, while our staging and production server are linux. We got some tasks which are done by a shell-script on linux. These tasks include: - Move files and folders (e.g. Testfiles on the staging folder) - Set folder permissions - run various commands

Right now, the shell scripts only are executed on the linux servers as they are not working on the windows machines. We would like to get to a point where we can run one script and, depending on environment, it executes the correct tasks.

Which language to choose for this tasks? I heard good things about python, but don't know if it really fits. I know some Perl, but don't think it's a good tool. Maybe there are languages which are designed for such problems?

EEAA
  • 108,414
  • 18
  • 172
  • 242
Sgoettschkes
  • 189
  • 1
  • 1
  • 9

3 Answers3

4

The Good answer: Move to linux on your desktops/laptops. You should be developing on the same platform the application is being served from.

The Hack-it-together-and-it-might-halfway-work answer: install cygwin on your dev machines, and you'll be able to run shell scripts.

EEAA
  • 108,414
  • 18
  • 172
  • 242
3

Are you saying that the problem is you're developing on Windows but deploying on Linux, and have scripts you want to run on both? I think you're going to find there are always some quirks unless there are some equivalent to #ifdef's in the script to figure out if it's running on Windows versus Linux, since there will be directory structure differences and such. Is there a reason you can't develop on a Linux system, or virtualize a Linux system on the Windows box so you're developing on the same platform you're building on?

You can get Python for Windows to run natively. And if you're using a UNIX-centric scripting language to do things (like Bash) you could install cygwin under Windows to have a POSIX environment in which to run things.

Personally, I'd virtualize a Linux system and save yourself some porting quirks and headaches. If you're asking for scripts that run under CRON on the server, install Cygwin and script it in Bash.

Bart Silverstrim
  • 31,092
  • 9
  • 65
  • 87
3

There are many cross platform languages that work for system administrative tasks. Perl, Python, and Ruby are all valid choices.

But those languages will not be able to auto-magically translate things that only make sense on Linux to the closest Windows equivalent. Setting permissions is different on Windows vs Linux. You will have to detect the OS and call the correct appropriate functions for that system.

Which language to choose for this tasks?

Choose a cross platform language that you are already familiar with. If you don't have any strong familiarity with any, pick one that looks cool.

Since you are developing PHP apps, you could always just install the PHP CLI everywhere. Since you are already using PHP you are familiar with it. While many might argue that PHP sucks, you can certainly get things done with it, and you are already using it.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • I know I have to do some double code for windows and linux, but that would be fine. The main problem right now is simply that the shell scripts are only running on the servers and the tasks performed need to be done manually on the development pcs. I don't think we'll use php for it, but I'll definitly have a look at python. – Sgoettschkes Sep 01 '11 at 08:39