Shell Command To Applescript

Hello, I'm making an Automator-Applescript app that copies icons from files and folders to other files and folders of one's choosing and it's coming along nicely with one exception-copying pictures. As you know, when you get info on a picture, it's icon appears on the top left of the info window. Some pictures have a generic icon and others have an icon of the picture. So, in order for this app to work properly using a picture, the picture must have an icon of the picture and not the generic icon. I have a shell script that will give a picture the desired icon but I was wondering if I can convert the shell script to an Applescript or if there's an Applescript that will achieve this. According to the Automator app the shell is /bin/bash, the pass input:as arguements, and the script is sips -i "$@" Thanks!
eMac G4   Mac OS X (10.4.9)  

Thanks for the reply. I tried the script and received-Warning: i not a valid file - skipping
Error 4: no file was specified
Try 'sips --help' for help using this tool.
Actually, what I'm trying to do is to add this shell command to an Applescript. Here's the Applescript- on run {}
set theSourceObject to my DetermineLocationOfObject("source")
set theTargetObject to my DetermineLocationOfObject("target")
my ApplyCustomIcon(theSourceObject, theTargetObject)
end run
to DetermineLocationOfObject(ObjectType)
display dialog "Is the " & ObjectType & " object going to be a file or a folder?" buttons {"File", "Folder"} default button 2
if button returned of the result is equal to "File" then
set theObject to choose file with prompt "Please locate the " & ObjectType & " file."
else
set theObject to choose folder with prompt "Please locate the " & ObjectType & " folder."
end if
return theObject
end DetermineLocationOfObject
to ApplyCustomIcon(SourceObject, TargetObject)
my HandleInfoWindow("source", SourceObject)
my HandleInfoWindow("target", TargetObject)
end ApplyCustomIcon
to HandleInfoWindow(ObjectType, theObject)
tell application "Finder"
activate
set InfoWindow to name of (open information window of item theObject)
end tell
tell application "System Events"
tell application process "Finder"
tell window InfoWindow
keystroke tab
if ObjectType is equal to "source" then
keystroke "c" using command down
else
keystroke "v" using command down
end if
end tell
end tell
end tell
tell application "Finder"
close window InfoWindow
end tell
end HandleInfoWindow
As you can see this is a good script for copying and pasting icons but when you choose a picture with a generic icon it will copy the generic icon. So, I was hoping to add this shell command to create the desired icon for the picture before the copying and pasting event. Thanks again.
eMac G4   Mac OS X (10.4.8)  

Similar Messages

  • Shell commands in applescript noob

    Hi all this is my first post in these forums and I come seeking help with a certain script I'm writing for my current college job. The purpose of the script is to install creative cloud from a server and this is as far as I've got. First I can get as far as setting the correct directory in the server by doing:
    do script "cd /Volumes/applications/Mac/'Adobe Creative Cloud'/'Enterprise - enduser'/Build"
    now when I press run the terminal screen pops up just fine with no errors in the right directory. However I've been reading up that to do other commands in the same shell I must do do shell script. When doing this however terminal doesn't do...anything. The reason why I was trying this is because my next command would be initiating the install which is the command:
    "installer -verbose -pkg 'enterprise_Install.pkg' -target /" with adminitrator privilages
    Now my question is how would formulate this within applescript? Thanks.

    do shell script "cd /Volumes/applications/Mac/'Adobe Creative Cloud'/'Enterprise - enduser'/Build ;  installer -verbose -pkg 'enterprise_Install.pkg' -target / with administrator privilages"
    You got the double quote in the wrong place.
    do shell script "cd /Volumes/applications/Mac/'Adobe Creative Cloud'/'Enterprise - enduser'/Build ;  installer -verbose -pkg 'enterprise_Install.pkg' -target / " with administrator privilages
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set unixDesktopPath to POSIX path of "/System/Library/User Template/"
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "sudo ls -l  " & quotedUnixDesktopPath with administrator privileges
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run

  • Applescript MySQL interface (No... not using the shell command)

    I'm a windows guy, so please be gentle if I sound noobish.
    I'm trying to automate an export of the System Profiler info to a MySQL database directly, and I was hoping to get applescript to parse the info from the XML and push it into MySQL.
    Now I know that Applescript can manipulate MySQL by using shell commands for the MySQL command line client, but I was hoping that someone knew of a native applescript interface.

    There's MacSQL http://www.macupdate.com/info.php/id/21293 that will give an alternative route into MySQL. I don't know whether it's any better than using shell scripts.

  • How to do multiple shell scripts in AppleScript

    I got some solutions from previous posts on how to run sudo in Applescript, but there is still some minor syntax issues when I try to get to the destination directory. Usually in shell script I just type
    cd directory-destination
    in several lines to batch process those commands, but when I work with applescript, if I do do shell script for every "cd" command, instead of getting an overall result, I would get intermediate results individually.
    I read doc and learned that there might be a way to put commands together by using the & sign?
    Message was edited by: ttback

    An individual do shell script command runs in its own shell, so to perform multiple commands within that shell you need to combine them into a single statement. You can use the ampersand '&' operator to concatenate text strings, and the semicolon ';' to separate the commands, for example:set theFolder to "/Applications"
    do shell script "cd " & theFolder & "; ls -l ."See the technical note do shell script in AppleScript.

  • Execute Shell command in Panel SDK Mac

    Hi,
    I´d like to execute the following task with a Panel:
    • render the active sequence
    • when finished send the output video file to another application using Apple Script
    The Panel SDK Examples are a great start. So the missing part is, how can I send a shell command that executes an AppleScript?
    In the ExtendScript Toolkit I found a function that looks promising. But executing this script only pops up an alert window saying "failed". Here´s the code:
    var test = UIAutomationSupport.helper.executeConsoleCommand("ls -l");
    alert(test);
    So does Premiere has an equivalent function like system.callSystem() in After Effects?
    Thanks,
    Thomas

    Bruce, thanks for your support!
    For those who are interested what bbb_999 refers to, here is how you can execute a shell command (in the example I use "osascript" to launch an AppleScript file):
    In your html file you simply write these simple lines of code
    <script type="text/javascript">
        function executeShellCommand(){
              var result = window.cep.process.createProcess('/usr/bin/osascript','/Users/myUserName/Desktop/test.scp t');
              alert(result.data+" "+result.err);
    </script>
    The first argument of createProcess() is the path to the shell tool.
    That´s all. Hope this helps others.
    Thomas

  • Do a perl command from applescript

    I'd like to use Perl from AppleScript for text replacements. The snippet below works, however when the var haystackString starts to include apostrophes, this fails. I tried using AppleScript's "quoted form of" on haystackString however it fails I think because the shell command I'm using needs single quotes to enclose the commands being executed by Perl. Any tips? Thanks, Ted
    set haystackString to "this this"
      set findString to "this"
      set replaceString to "that"
    set shellscript to ("perl -e '$s=\"" & haystackString & "\";$toFind=\"" & findString & "\";$replaceWith =\"" & replaceString & "\";$s =~ s/$toFind/$replaceWith/g;print $s;'") as string
      set testString to do shell script shellscript

    Hi,
    Ted Fitzpatrick wrote:
    however it fails I think because the shell command I'm using needs single quotes to enclose the commands being executed by Perl. Any tips? Thanks, Ted
    Yes, that's right.
    Solution, use the arguments:
    set haystackString to "can't  can't"
    set findString to "can't"
    set replaceString to "that's all"
    set args to (quoted form of haystackString) & " " & (quoted form of findString) & " " & quoted form of replaceString
    set testString to do shell script "perl -e '$s=\"$ARGV[0]\";$s =~ s/$ARGV[1]/$ARGV[2]/g; print \"$s\"' " & args

  • Set audio in/output with shell command

    Hi.
    I want to switch the systems audio input and output with a shell command. I've found a command that can set the volume. Maybe someone can tell me if this is possible and if so, which command i need.
    osascript -e "set Volume 0"

    I think there's a messy way of doing it in AppleScript by addressing the menus in the System Preferences. But if I were you I would have a look at the tool that someone has created here:
    http://code.google.com/p/switchaudio-osx/
    It addresses CoreAudio directly I think to change the input/output method:
    will@Newton:~/Downloads/SwitchAudioSource-v1> ./SwitchAudioSource
    Please specify audio device.
    Usage: ./SwitchAudioSource [-a] [-c] [-t type] -s device_name
    -a : shows all devices
    -c : shows current device
    -t type : device type (input/output/system). Defaults to output.
    -s device_name : sets the audio device to the given device by name
    will@Newton:~/Downloads/SwitchAudioSource-v1> ./SwitchAudioSource -a
    Built-in Microphone (input)
    Built-in Input (input)
    Built-in Output (output)
    will@Newton:~/Downloads/SwitchAudioSource-v1> ./SwitchAudioSource -c
    Built-in Output
    will@Newton:~/Downloads/SwitchAudioSource-v1> ./SwitchAudioSource -t input -s 'Built-in Input'
    input audio device set to "Built-in Input"

  • Calling Shell commands in C programme

    How would i call shell command using C programme.

    #include <unistd.h>
    #include <sys/types.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <wait.h>
    int main(void) {
    pid_t pid;
    pid = fork();
    if (pid == 0) {
    execl("/bin/sh", "sh", "-c", "/bin/ls -l > /tmp/ls", NULL);
    exit(1);
    else if (pid > 0) {
    wait(NULL);
    else {
    return -1;
    return 0;
    }

  • Run shell commands using java program

    Hi guys,
    I am trying to run shell commands like cd /something and ./command with arguments as follows, but getting an exception that ./command not found.Instead of changing directory using "cd" command I am passing directory as an argument in rt,exec().
    String []cmd={"./command","arg1", "arg2", "arg3"};
    File file= new File("/path");
    try{
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(cmd,null,file);
    proc.waitFor();
    System.out.println(proc.exitValue())
    BufferedReader buf = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    catch(Exception e)
    {e.printStackTrace();
    So can anyone please tell me what is wrong with this approach? or is there any better way to do this?
    Thanks,
    Hardik

    warnerja wrote:
    What gives you the idea that the process to execute is called "./command"? If this is in Windows, it is "cmd.exe" for example.It does not have to be cmd.exe in Windows. Any executable or .bat file can be executed as long as one either specifies the full path or the executable is in a directory that is in the PATH.
    On *nix the file has to have the executable bit set and one either specifies the full path or the executable must be in a directory that is in the PATH . If the executable is a script then if there is a hash-bang (#!) at the start of the first line then the rest of the line is taken as the interpreter  to use. For example #!/bin/bash or #!/usr/bin/perl .
    One both window and *nix one can exec() an interpreter directly and then pass the commands into the process stdin. The advantage of doing this is that one can change the environment in one line and it  remains in effect for subsequent line. A simple example of this for bash on Linux is
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    public class ExecInputThroughStdin
        public static void main(String args[]) throws Exception
            final Process process = Runtime.getRuntime().exec("bash");
            new Thread(new PipeInputStreamToOutputStreamRunnable(process.getErrorStream(), System.err)).start();
            new Thread(new PipeInputStreamToOutputStreamRunnable(process.getInputStream(), System.out)).start();
            final Writer stdin = new OutputStreamWriter(process.getOutputStream());
            stdin.write("xemacs&\n");
            stdin.write("cd ~/work\n");
            stdin.write("dir\n");
            stdin.write("ls\n");
            stdin.write("gobbldygook\n"); // Forces output to stderr
            stdin.write("echo $PATH\n");
            stdin.write("pwd\n");
            stdin.write("df -k\n");
            stdin.write("ifconfig\n");
            stdin.write("echo $CWD\n");
            stdin.write("dir\n");
            stdin.write("cd ~/work/jlib\n");
            stdin.write("dir\n");
            stdin.write("cat /etc/bash.bashrc\n");
            stdin.close();
            final int exitVal = process.waitFor();
            System.out.println("Exit value: " + exitVal);
    }One can use the same approach with Windows using cmd.exe but then one must be aware of the syntactic differences between commands running in .bat file and command run from the command line. Reading 'help cmd' s essential here.
    The class PipeInputStreamToOutputStreamRunnable in the above example just copies an InputStream to an OutputStream and I use
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class PipeInputStreamToOutputStreamRunnable implements Runnable
        public PipeInputStreamToOutputStreamRunnable(InputStream is, OutputStream os)
            is_ = is;
            os_ = os;
        public void run()
            try
                final byte[] buffer = new byte[1024];
                for (int count = 0; (count = is_.read(buffer)) >= 0;)
                    os_.write(buffer, 0, count);
            } catch (IOException e)
                e.printStackTrace();
        private final InputStream is_;
        private final OutputStream os_;
    }

  • Incorporate shell commands from forms

    How to incorporate unix shell commands(eg. ls, cp) from forms9i?
    In Windows environment,it is possible by issuing
    host command(eg. HOST('DIR >k.lis') -- it moves the list of files from Oracle9i/forms90 path to a file k.lis).
    The same thing I have to do in a unix environment.

    I think you have the wrong forum. This forum has to do
    with the UIX technology inside of JDeveloper. Your
    question seems to have to do with UNIX or forms. I can't
    tell which.

  • Executing shell commands from Java.

    I want to execute shell commands in Java using the Runtime.exec( String ) method.
    The method works fine under Linux OS, but under Windows '98 the method didn't work at all!
    For example the following call: Runtime.exec( "dir" ) throws an exception showing that the command was not completed. If I replace dir with ls under Linux all is good. What is the problem with the Microsoft Windows '98 ? Is there any solution at my problem ?!
    thx in advance!

    hey JSarmis,
    You can help me... "ls" doesn't work for me on linux.. using Runtime.exec, some commands work, others don't... you may hold the key to what i need? How did u get "ls" to work?

  • How to retrive ip address of connected device in shell script or applescript

    Hi all,
    From Mac PC, how to get ip address of connected device in shell script or applescript.
    there is any way to launch an app on ipad in shell script or applescript.
    thank you in advance for your help
    Mickael

    Hi all,
    From Mac PC, how to get ip address of connected device in shell script or applescript.
    there is any way to launch an app on ipad in shell script or applescript.
    thank you in advance for your help
    Mickael

  • Running Shell Commands (not Executable) in Unix from Java

    What are my options to run shell commands from Java?
    My goal is to change my existing shell environment variables to some new ones provided by .anotherProfile.
    Using an executable from Java is not an option because it does not work i.e. ( exec(". /home/.profile") ) brings up errors.
    Someone has suggested that I start a child shell with that profile and work from there, but I'm unfamiliar with that sort of syntax and programming in general.
    Any good help equals duke dollars :)

    Well there are some possibilities. In the original thread you mentioned that you wanted the shell script to be executed to change some enviroment parameters of the shell the JVM is executing in.
    If so, and you are able to rewrite the profile so you can parse it manually. Then you can change some environment setting by writing the JNI wrappers for the getenv and setenv system calls. (Check your man pages)
    That will change the environment. I am just wondering what good it will do for you? What's use of sourcing the profile in a JVM?

  • Shell Commands

    I have 100 shots I need to render. I know how to submit the shots to qmaster using a shell command, but my problem is that I can only figure out the syntax to have one job per line. That means that instead of one batch with 100 jobs, I get 100 batches, each with 1 job.
    Can anyone clue me in to how I can do this? Here is the code I use per line -
    /Applications/Apple\ Qmaster.app/Contents/MacOS/Apple\ Qmaster -batchname test -clustername testxsan -command "Shell" -options \<command\>test.pl\ a bunch of options and stuff go here\<\/command\>
    The manual also says something about XML commands, although I could not find the file it was referencing at ~Library/Preferences/com.apple.AppleQmaster.plist.

    Hi Dylan,
    I hope this helps. You're real close. Once you set your batch name and send it the job information for the first job, just include the other jobs that you want in batch.
    You can include the same source file multiple times and reference different settings files to create multiple versions of the same clip. Or you can include multiple clips using the same settings files. Or you can mix and match.
    The thing is you have to specify everything for each job.
    Here's an example of one where you send multiple clips using the same settings file. I've broken it out on separate lines to make it easier to read.
    --tom
    /Applications/Compressor.app/Contents/MacOS/Compressor
    -clustername MyVideoCluster
    -batchname MyBigBatchName
    -jobpath /Users/path/to/source/MyVideoClip01.flv
    -settingpath /Users/path/to/video/settings/SettingFileName.setting
    -destinationpath /Users/path/to/output/MyVideoClip01-DONE.mov
    -jobpath /Users/path/to/source/MyVideoClip02.flv
    -settingpath /Users/path/to/video/settings/SettingFileName.setting
    -destinationpath /Users/path/to/output/MyVideoClip02-DONE.mov
    -jobpath /Users/path/to/source/MyVideoClip03.flv
    -settingpath /Users/path/to/video/settings/SettingFileName.setting
    -destinationpath /Users/path/to/output/MyVideoClip03-DONE.mov

  • How to run 'Get-AssignedAccess' or 'Set-AssignedAccess' power shell commands in c# Application

    Hi,
    I have console application using which i am trying to run power shell command  like 'Get-AssignedAccess' or 'Set-AssignedAccess'.
    i am using below code for this it is throwing exception 'Get-AssignedAccess' doesn't exist in cmdlet which is correct because these commands belongs to function category.
    using (PowerShell pwInstance = PowerShell.Create())
                            pwInstance .AddScript("Get-AssignedAccess");
                            var result = pwInstance .Invoke();
    How can we execute this kind of command using c#?
    Thanks,

    Hi prakashlight,
    Thank you for comming back and tell us the result. For more information about how to run PowerShell script in C# language, you can refer to this blogpost here:
    Executing PowerShell scripts from C#
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for