Re: Command line text substitution
Re: Command line text substitution
- Subject: Re: Command line text substitution
- From: Doug McNutt <email@hidden>
- Date: Sat, 18 Jan 2003 18:20:51 -0700
At 15:00 -0800 1/18/03, Paul Berkowitz wrote:
>
If you're not concerned with AppleScript here (which would be odd), or are
>
scripting the Terminal application, then it's tcsh for sure.
Actually I think AppleScript may use the Terminal in order to run a shell script I have prepared. When I use a two liner to simply do shell script pointing to something I prepared for tcsh and stored as an executable with a #!/bin/tcsh as the first line it surely gets executed by tcsh and not by bash or sh.
But. . . my script is entered with $SHLVL at stage 2. Applescript is not going directly to my script and executing it. It is using an intermediate application and I think it must be Terminal though I guess it could be a copy of bash that doesn't notice my $HOME/.bashrc which I created just to test. It does a couple of simple echos redirected as >> $HOME/logs/shell_log. They are not getting executed.
There is also the problem of how to set $PATH the way I want it. AppleScript presumably pays attention to $HOME/.MacOSX/environment.plist but Terminal will overlay that if it causes execution of /etc/csh.login, which, as provided by Apple, has it's own ideas. I now set PATH in my $HOME/. tcshrc where I test for $SHLVL < 3 to allow changes when called by AppleScript but that can get multiple copies of a directory into the path.
But given it all. AppleScript is a whole lot better way to get a script executed at, say, login time than adding a .command extension to force execution by Terminal. That leaves a window open requiring action by a user. Using full path names rather than depending on $PATH is a good procedure providing you're don't want to move scripts to another Mac with another user.
I would like to try doing something like 'do shell script "setenv NAME = doug"' to see if the one liner goes to bash or to csh but such things are lost anyway because AppleScript gives you a new environment for each do shell script and you can't go back to Terminal or BBEdit and ask what environment variables were set during your login session to Mac OS neXt. When one logs in to Jaguar one is not logging in to the "real" operating system.
I have been using this Script APPL for a couple of months now and I am pleased with it. Drop your shell script on it and it happens. The only thing better would be to have a finder which would execute double clicked executable files.
-- This section runs while in the script editor.
-- Starting point is selection in the finder.
tell application "Finder"
set argList to selection
repeat with theTarget in argList
set bbb to theTarget as alias
set aaa to POSIX path of bbb
set thePath to aaa as string
my doStuff(thePath)
end repeat
end tell
-- This happens when icons are dropped onto the script in Applet form.
-- Note that finder resolves any aliases even though it delivers alis's in arglist.
on open (argList)
tell application "Finder"
repeat with theAlias in argList
set aaa to POSIX path of theAlias
set thePath to aaa as string
my doStuff(thePath)
end repeat
beep
end tell
end open
on doStuff(aPath)
do shell script aPath
end doStuff
--
--> If you are presented a number as a percentage, and you do not clearly understand the numerator and the denominator involved, you are surely being lied to. <--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.