APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > News Posts > Mac Os X scripting:
Printer Friendly Version




News Group Posts

script files on Mac OS X



From: Bob Harris <nospam.News.Bob@remove.Smith-Harris.us>
Subject: Re: wget -- input file delimiters?
References: <0001HW.BEDAEF200031CD2FF02845B0@news.readfreenews.net>
<190620051347235059%doozy@earthling.net.invalid>
<tomstiller-2B54F4.14074619062005@comcast.dca.giganews.com>
<0001HW.BEDB22ED0000A058F04885B0@news.readfreenews.net> Message-ID: <nospam.News.Bob-AEDD7D.19284219062005@news.verizon.net> Date: Sun, 19 Jun 2005 23:28:17 GMT In article <0001HW.BEDB22ED0000A058F04885B0@news.readfreenews.net>, DaveC <me@privacy.net> wrote: > Thus spake Tom Stiller: > > > In article <190620051347235059%doozy@earthling.net.invalid>, > > Philo D <doozy@earthling.net.invalid> wrote: > > >> CR = control-M > >> LF = control-J > > > Get the free application TextWrangler from Bare Bones Software. It > > allows one to specify the line ending to be used. > > Thanks, guys. > > Also, I'd like to know how to specify the wget command and all its parameters > in a file and execute it from Terminal. > > Possible? If so, how (preferably w/o scripts)? > > Thanks, use and editor such as TextWrangler <http://www.versiontracker.com/dyn/moreinfo/macosx/18529> Then enter the #! line shown below followed by any number of commands line want to be executed in sequence: #!/usr/bin/sh # have this bit of magic as the very 1st line wget ... Then use "Save as..." -> Options -> Line Breaks -> UNIX to get a file with <LF> as your line terminators. Or you can use an editor such as pico (/usr/bin/pico) to edit your file from the terminal: pico your_wget_file #!/usr/bin/sh # have this bit of magic as the very 1st line wget ... Control/O # to write your file out Control/X # to exit pico One final thing, execute the following command: chmod +x your_wget_file This will make your command executable. But wait there's more. Isn't this fun? :-) Ideally, you want this file to be stored in a directory that is part of your "PATH". Where PATH is a UNIX environment variable that contains as list of directories the shell (giving your your command line prompt in the Terminal window) will search looking for executable files that match the name of the command you type. echo $PATH will give you a colon separated list of directory paths. I personally create a $HOME/bin directory where I stick my personal commands mkdir $HOME/bin mv your_wget_file $HOME/bin You could create this from the Finder, and drag and drop your_wget_file into $HOME/bin via the Finder. Then I edit my .bash_profile file (if running the bash shell), or .login if running the tcsh or csh shells, or the .profile if running ksh or sh shells, and in the .bash_profile, or .login, or .profile, I put: export PATH="$HOME/bin:$PATH" # sh, ksh, bash, zsh or setenv PATH "$HOME/bin:$PATH" # csh, tcsh I also explicitly set the access permissions to: chmod 644 $HOME/.bash_profile or chmod 644 $HOME/.login or chmod 644 $HOME/.profile Some people set the permissions even more strict, but I do not care if anyone reads my script initializations, just so no one can change them. Another approach is to give the file a .command suffix as in your_wget_file.command and make the file executable chmod +x your_wget_file.command then you can double click on it from the Finder. However, I don't really like this as it always seems to open up a new terminal window and then leave the window hanging around. Not my cup of tea. You can so do things like create an AppleScript to launch your shell commands in a file (I know I'm skating dangerously close to calling the shell commands in a file a script :-) on open filelist repeat with i in filelist -- next line that looks like 2 is all one long line do shell script "$HOME/bin/your_wget_file >/dev/null " & quoted form of POSIX path of i end repeat end open If there are no drag and drop files to be processed, then you can omit the & quoted... stuff on open filelist repeat with i in filelist do shell script "$HOME/bin/your_wget_file >/dev/null" end repeat end open The >/dev/null makes sure that anything spit to standard output by your_wget_file will be thrown away. Take it out if you want to see what gets spit out. You would use create this tiny little Applescript using Applications -> Applescript -> Script Editor and "Save as..." Application or Application Bundle. Now you would have double clickable (or drag and drop'able) program like thing that would run your wget command(s) Bob Harris
If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

Comments?



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Auto FTP Manager

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

g_face.jpg

This post tagged:

       - MacOSX




Unix/Linux Consultants

Skills Tests

Guest Post Here