views:

188

answers:

2

The particular alias I'm looking to "class up" into a Python script happens to be one that makes use of the cUrl -o (output to file) option. I suppose I could as easily turn it into a BASH function, but someone advised me that I could avoid the quirks and pitfalls of the different versions and "flavors" of BASH by taking my ideas and making them Python scripts.

Coincident with this idea is another notion I had to make a feature of legacy Mac OS (officially known as "OS 9" or "Classic") pertaining to downloads platform-independent: writing the URL to some part of the file visible from one's file navigator {Konqueror, Dolphin, Nautilus, Finder or Explorer}. I know that only a scant few file types support this kind of thing using some other command-line tools (exiv2, wrjpgcom, etc). Which is perfectly fine with me as I only use this alias to download single-page image files such as JPEGs anyways.

I reckon I might as well take full advantage of the power of Python by having the script pass the string which is the source URL of the download (entered by the user and used first by cUrl) to something like exiv2 which could write it to the Comment block, EXIF User Comment block, and (taking as a first and worst example) Windows XP's File Description field. Starting small is sometimes a good way to start.

Hope someone has advice or suggestions.

BZT

+5  A: 

The relevant section from the Bash manual states:

Aliases allow a string to be substituted for a word when it is used as the first word of a simple command.

So, there should be nothing preventing you from doing e.g.

$ alias geturl="python /some/cool/script.py"

Then you could use it like any other shell command:

$ geturl http://example.com/excitingstuff.jpg

And this would simply call your Python program.

unwind
You can also use a shebang like `#!/usr/bin/env python` in your script and do `alias geturl="/some/cool/script.py"`
Dennis Williamson
Right. Many thanks to both unwind and Dennis. I've been looking into Python modules that read and write comment, EXIF and IPTC data to JPEG files, and now I suppose I'll be looking for help writing a script to either "call" cUrl or do the downloading itself along the same lines as its -o (output to file; user supplies the filename) option. Advice on this part would be appreciated as well, of course.BZT
silversleevesx
A: 
silversleevesx
Okay now that's out of my system (and no "Command not found" errors either LOL)....I found a nice wget emulator script on ActiveState.com that seems to work, but in cUrl terms it mimics the "-O" option, which unlike wget, means 'use the same file name as on the server.' How would I change it to mimic the other option? (I'd like to elicit an answer to this comment before posting the code.) BZT
silversleevesx