applescript alternative in Linux

What is the applescript alternative in Linux?

Basically, with applescript I do tasks like:

  1. Linking several tasks in one like changing the resolution of an image, zipping it and then moving it to a folder
  2. Using some web services like Twitter, Dropbox etc
  3. Scripting iTunes
  4. Processing selected files and folders in Finder
  5. Emails ------ I select text in any application and send it as an email to a select group of friends or any one of them.

If possible, also point me to scripts which do the above in Linux?


  1. My suggestion is to learn shell scripting basics. Then depending on whatever scripting languages your most familiar with, you would write shebang scripts for your tasks in them. Common on linux systems are
    the shells (ksh,sh,bash etc)
    higher languages ruby, php, python
    and a lot more like perl and C which are not really the level you are looking for.
    I do my image manipulations with gdlib via php. It’s faster and much more reliable than imageEvents in AppleScript.
    I do wrap these scripts in AppleScripts, just for drag and drop capabilities.

  2. don’t quite understand what you mean. Do you mean using their APIs with XML-HTTP-calls?

  3. iTunes on linux? Look for command line players, they often come with a bunch of options.

  4. depends on your distro what and how far the gui can be scripted…don’t expect too much. AppleScript is one of those things power users from other platforms are secretly envious about Macs

  5. … once you learnt basic shell commands plus ruby, php or python, you will feel comfortable enough there, that you won’t need much gui scripting :wink:

In a linux world you will feel a lot more comfortable if you have some basic shell knowledge.

in short: to my limited knowledge, no, there’s nothing that comes close to AppleScript.

something to get you started:

then your php script might look like this (depending where the php interpreter resides):

<?php echo 'hello world'; exit(0); ?>

in ruby it would be:
print ‘hello world’

for more specific help, look for forums specialised to your distribution

There is no good, single equivalent to AppleScript in Unix-ish environments outside Mac OS X.

“Internal” Scripting
For intra-application scripting, many applications embed languages for use in configuration and customization, but there is little standardization as to which language(s) are embedded. Tcl was designed to be embedded into applications, but many applications seem to prefer embedding a more trendy (or at least previously trendy) language like Perl or Ruby. Some less well-known examples of embeddable languages include S-Lang, io, and Lua. Lisp, and Scheme are common bases for custom languages (like Emacs Lisp). Sometimes applications use completely novel languages. Finally, not all applications embed languages at all (even in Mac OS (X), not all applications support AppleScript).

“External” Scripting
One view of the Unix philosophy is “small, specialized, composable programs that read and write text streams”. This view tends to emphasize inter-command scripting. The most common composition method is filtering (utilized as ˜pipes’ and ˜I/O redirection’). The idea is that the user can string together a host of small, specialized commands to create more complex pieces of functionality (which then might themselves be composed).

Some of the most common programs used this way include grep (filters out lines that match/do-not-match a “regular expression” (a (set of) mini-languages that are recurring themes in many tools/programs/commands/applications)), sort (sort lines according to various parts of the line), head (extract some of the first lines of an input stream, discarding the rest), tail (extract just the last lines of an input stream, discarding the rest), find (recursively search for files that match given criteria and produce a stream of pathnames), xargs (consume a stream of arguments and integrate them into new command strings), ls (list files), cp (copy files), mv (move/rename files), rm (delete files), curl/wget (HTTP/FTP/. upload/download), etc.

As an example, for your “#1” item, you might use convert from ImageMagick for image resizing, zip for zipping, and mv for moving. mv is standard, zip is usually standard (Info-ZIP is open source), ImageMagic is open source and is probably available on most systems (it has pre-compiled binaries available (or you could use something like MacPorts to compile it for you)).

The core of such scripting can be almost any “scripting” language that makes it easy to run other commands with some minimal amount of control over the supplied input and the generated output. The most common languages used in this area are the “shells”. Chief among the shells are those that are related to the Bourne shell (the traditional /bin/sh). The Bourne-type shells include sh, ash, dash, ksh, bash, and zsh (maybe a few others, too; often sh is a compatibility-mode version of one of these other shells). One or more of these shells is present on every modern Unix-ish system and almost every other Unix-ish system from the past three decades. This makes Bourne shell scripting the number one environment for portable command scripting.

When (extreme) portability is not a requirement, or when the required manipulations become more complex, some of the more recently developed languages are often used in the place of a shell language. The common ones are Perl, Python, Ruby, and Tcl, though there are many, many other candidates.

Learning to script in a Unix-ish environment will come in two parts: the language (take your pick), and the “library” (all the small programs that can be combined together in useful ways, plus the library of functionality included with your language). I know of no shortcut to learning all the small programs. Read others’ scripts, ask task-oriented questions in scripting-related communities (Usenet, forums, mailing lists, groups, Q&A sites, etc.). For each of the languages, there are probably one or more books available and many free online tutorials and resources.

Eventually, you may come to a situation where you want to do some intra-application scripting but the application does not support any of the languages you know. First, try to approach the problem from a different perspective. You might be able to reimplement the functionality in your preferred language with the help of some of the composable tools you have already learned. If that is not possible, you now have an opportunity to broaden your knowledge. Start to learn the new language. If the new language is different enough from what you already know, learning the new language will often make you a better programmer/scripter/user because it forces your mind to generalize and reinterpret your existing knowledge.

Many thanks for the replies. I don’t think I can learn so many different languages and atleast it does not seem worth the effort.

Long live applescript!!