
# Ce fichier servira à lancer stead sous macosX par drag-and-drop pour
# éditer plusieurs fichiers

########################################################################


Andreas> Hi.  Does anyone know of an easy way to write an AppleScript           
Andreas> script to launch a UNIX application and supply command line            
Andreas> args to it?                                                            
                                                                                
Besides                                                                         
                                                                                
        do shell script "command line here with args"                           

########################################################################
Create a drag and drop interface to shell scripts                               
Mon, Nov 25 '02 at 09:01AM ? from: ClarkGoble I didn't come up with this        
hint, but have used it enough so as to submit it. A lot of people have          
created application "wrappers" for shell scripts using either dropscript        
or iHook. However they don't always do the job like you may wish. An            
alternative is to use Applescript.                                              
                                                                                
For instance if you wish to run a Unix command on each file you drop on         
the Applescript you can do the following:                                       
                                                                                
on open filelist                                                                
  repeat with i in filelist                                                     
    do shell script "my_command " & POSIX path of i                             
  end repeat                                                                    
end open                                                                        
                                                                                
A nice feature of OSX is that you can associate any application with a          
kind of file. First save your script using Script Editor as an                  
application. Then select a file of the type you wish to associate with          
your script. Select "Get Info." Select the "Open with" pane and then            
select your Applescript application. Click the "Change All" button. Now         
every file of that extension will open up with your Applescript.                
                                                                                
This is very nice for running some shell command on the file for                
filtering it before opening it with another file. For instance, you can         
use the following script to open PostScript files in Acrobat. It works          
by using ps2pdf (available as part of Fink) to first convert the file to        
a temporary PDF file. You can obviously make this a little more robust          
if you open multiple PostScript files at the same time.                         
                                                                                
on open input_file                                                              
  do shell script "export PATH=\"$PATH\":/sw/bin;ps2pdf \"" &                   
  POSIX path of input_file & "\" ~/.psview.tmp.pdf; open                        
~/.psview.tmp.pdf"                                                              
end open                                                                        
                                                                                
The "do shell script" command is shown on two lines; enter it as one            
line with a space after the "&".                                                
                                                                                
[Editor's note: I have not tested this hint myself.]                            
Comment on this hint ... Email this hint                                        
                                                                                
 
# 