Terminal Commands Using AppleScript

Hi,
I have some AppleScripts that access Terminal to send some commands to an Arduino.
I'm hoping there's a way to keep Terminal from opening a new window each time
I access it with a command?
Thanks,
Carl

Are you using "do shell script" to execute your commands?  The "do shell script" does NOT open a terminal window.
The Terminal does not execute commands, it is just a viewing device and keyboard handler for humans.  The Terminal just passes your keyboard input the the shell and/or programs you run from the shell, and displays what the shell and programs run from the shell return.
The Terminal itself is not needed to run Unix commands.  The "do shell scrpt" is one way to execute commands without the need for the Terminal.

Similar Messages

  • Executing terminal command using JavaCode

    Hi,
    My requirement is to set JVM heap memory -Xms and Xmx using java code.
    I search for this and find out a solution for windows. Wanted a similar solution for Mac as well.
    Here is the code which i used for Windows.
    Runtime.getRuntime().exec("cmd.exe /c java -Xms250m -Xmx1024m -jar \"application.jar\" /n");
    Can any one tell how i can achieve similar kind of functionality for Mac.
    Thanks,

    Hi,
    Thanks for replying.
    I has try these but no success
    *proc = Runtime.getRuntime().exec("Terminal java -Xms250m -Xmx1024m -jar \"Application.jar\" /n");
    proc = Runtime.getRuntime().exec("java -Xms250m -Xmx1024m -jar \"Application.jar\" /n");
    proc = Runtime.getRuntime().exec("/usr/bin/open -a Terminal java -Xms250m -Xmx1024m -jar \"Application.jar\" /n");*
    Please let me know where i doing wrong

  • Terminal Command to Re-Mount an Unmounted Local Disk Partition?

    Hello,
    Does anyone know a terminal command (or applescript command) to re-mount an unmounted local disk partition? I know it can be done using the DiskUtility, but I would like to do it from the Terminal without launching another program.
    Using Tiger 10.4.5 on a G5
    Thanks,
    Tom
    G5 2.3 MHz dual core   Mac OS X (10.4.5)  

    Hi Tom,
       AppleScript will execute anything that you can exectute from the command line that isn't interactive but it won't execute it in the same way. By that I mean that the environment will be more vanilla. In this case the problem is that the path is rather basic. All you have to do is to use an absolute path to the script and it should work. Apple has a pretty good reference for the mechanism, Technical Note TN2065: do shell script in AppleScript.
       Is wakeonlan basically the same thing as waking upon receipt of a "magic packet"? I think you can easily make Mac OS X do that by itself. Just open System Preferences and the "Options" tab of the "Energy Saver" pane. Check the checkbox beside "Wake for Ethernet network administrator access".
    Gary
    ~~~~
       I gave my love an Apple, that had no core;
       I gave my love a building, that had no floor;
       I wrote my love a program, that had no end;
       I gave my love an upgrade, with no cryin'.
       How can there be an Apple, that has no core?
       How can there be a building, that has no floor?
       How can there be a program, that has no end?
       How can there be an upgrade, with no cryin'?
       An Apple's MOS memory don't use no core!
       A building that's perfect, it has no flaw!
       A program with GOTOs, it has no end!
       I lied about the upgrade, with no cryin'!

  • Using Applescript to execute a Terminal command

    I've looked at the possible answers that come up when I ask this question here, but none really fit my question.
    I want to automate the Terminal command that cleans out obsolete entries in my right-click "Open with" menu, which I have to do often. Rather than copying the command each time I want it, then opening Terminal, pasting it in, etc., is there a way to automate this with Applescript?  Thanks!

    Thanks for the fast reply, Niel. I understand this is a newbie Applescript question, but over the years I have just never used Applescript and other than this one thing, probably won't again.  So rather than take hours to learn it, I hope you don't mind the additional question regarding this.  Do I just put the following into the main Applescript editor?
    do shell script "ls -l ~"
    /System/Library/Frameworks/CoreServices.framework//Versions/A/\
    Frameworks/LaunchServices.framework/Versions/A/Support/lsregister \
    -kill -r -domain local -domain user;
    killall Finder

  • Using automator/applescript to do terminal commands/ssh

    hi,
    pardon my extreme novice question here, but i was looking for quick & easy ways to create a small applet to basically run a script on a web server to remotely check & update it's IP address with its web host, and also serve internet services to a wifi access point.
    here's the basic stuff we usually do in terminal —
    my-Computer:~ admin-user$ ssh admin@+{web server IP, ex.: 0.0.0.0}+
    +{we then have to wait for it to connect and ask for a password}+
    Password: {our input for password}
    Last login: Sat Jun 14 15:04:58 2008 from 0.0.0.10
    Welcome to Darwin! +{so we are now connected}+
    www:~ webserver-admin$ sudo /var/root/IP_update.sh
    +{there is then a long output as that script runs and updates the IP with the web host}+
    www:~ webserver-admin$ sudo route add -net 0.0.0.0/24 0.0.0.3 +{serve up internet services to a wifi access point, returns output that it was done, failed or already connected}+
    www:~ webserver-admin$ sudo /opt/local/sbin/lighttpd -f /opt/local/etc/lighttpd/lighttpd.conf & +{starts up our web server, returns that it was started or already on because port 80 is in use}+
    so that's what i want it to do. i thought using automator and the *run shell script* option in it would work, but i can't even get past the first ssh command without an error. i have it set to use /bin/sh, and have tried it with *pass input* setting set either way, *to stdin* or as arguments, but in either case, just on this first line alone, i get the following error —
    Run shell script failed
    Pseudo-terminal will not be allocated because stdin in not a terminal.
    does anyone know why this is happening? how do i get around this and proceed on with my script using automator?
    also, if anyone could please give tips about how to use the "pause" to have it wait for prompts over the network (like the "Password:" prompt coming back after an indeterminate number of seconds) and which automator command might be used to pop up a dialogue for user input (like asking for the password), it would be much appreciated. thanx.

    You'd want the *do shell script* command in AppleScript for this
    http://developer.apple.com/technotes/tn2002/tn2065.html
    however you're not going to be able to use it as you would tools such as Expect which allow you to wait and provide additional input on stdin. If all you're doing is updating an IP address why not simplify the entire mess with BIND's dynamic updates?

  • Applescript to run terminal command then open application..

    Hey,
    I've installed the add-on to make the Lion Finder sidebar icons colored again, but whenever I reboot my Mac, I have to execute a killall Finder to get those icons back. This also closes TotalFinder, which is an addon I use. So, I want to write an AppleScript which will run on startup, and do those two things: run the Terminal command, and then open TotalFinder.
    I've written:
    tell application "Terminal"
        activate
        do script "killall Finder" in front window
        quit
    end tell
    tell application "TotalFinder"
        activate
    end tell
    This gives me an error stating "Connection is invalid." when running the activate line for TotalFinder. The Terminal command is executed correctly. Any idea why this is? The application is definitely named correctly, its just in my root Applications directory so it should be able to find it, etc. How can I get this working?
    Thanks!

    try this:
    do shell script "killall Finder"
    tell application "TotalFinder"
              try
      activate
              end try
    end tell
    First thing you don't need to open a terminal window to do the killall you can just do to as a shell script.
    Second don't know why TotalFinder gives that message about Connection invalid but it doesn;t seem to affect it any. So putting in the try just eats the error message.
    Ypu may not even need the killall, When TotalFinder starts it restarts the Finder so you may be able to remove the killall
    regards

  • Applescript Terminal Command Problem

    Hilo
    I am making an application that Alphabetizes words.
    Everything works except that whenever I get to this part -
    do shell script "cd ~/Public/Alphabetizer; ls -l *.pl; chmod +x Alphabetizer.pl; ./Alphabetizer.pl"
    does anyone know why nothing happens, and if you do,
    can you tell what to type to show what happens on terminal using applescript?
    ^_^ greatly appreciated

    What do you expect to happen? That command does not involve Terminal at all. If you want to check the stdout from the shell commands, you could use the Results pane and/or the Event Log in Script Editor. Or redirect the output to a file.
    If you want an actual Terminal window, you need to send the commands to Terminal, rather than directly to a shell. E.g.,
    tell application "Terminal"
    activate
    do script "ls -l"
    end tell
    Note that that is the Terminal's +do script+ command, not AppleScript's +do shell script+ command.

  • I get "App Store Disabled" on my MacBook Pro due to profile issues. What Terminal command can I use to reset profile settings?

    After transferring documents from one MacBook Pro to another I get some weird errors due to settings that seem to have transferred over. One is that the Mac App Store is disabled.
    Are there any Unix / Terminal commands I can use to reset these?

    Forgot Your Account Password
    For Lion/Mountain Lion
        Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
         When the menubar appears select Terminal from the Utilities menu.
         Enter resetpassword at the prompt and press RETURN. Follow
         instructions in the dialog window that will appear.
         Or see Reset a Mac OS X 10.7 Lion Password and
         OS X Lion- Apple ID can be used to reset your user account password.

  • How can I change the "Ask to join new networks" option using a terminal command?

    We are currently switching to a new wireless network throughout our school district and I have pushed commands to connect to the new and remove the old. However, any Macs that have "Ask to join new networks" enabled are jumping over to our unsecure guest network, even if that network has been removed from the list of Preferred Networks. So far the fix has been to remove the guest network from the list of Preferred Networks and then disable Ask to join. The only issue I'm running into now is I have been unable to find a terminal command to change this setting. Once I have the command I can write a script and send that out to all of the Macs.
    So is there a way to disable "Ask to join new networks" using command line?

    sed -i "" 's/Prompt/DoNothing/' /Library/Preferences/SystemConfiguration/preferences.plist

  • Terminal Command, how to set defaults write, make application(s) use directory path where file last saved?

    Does anyone know whether there's a terminal command to make all applications remember/use the last directory/path where I last saved a file?
    For example, let's say there are (10) ten PDF's on a website, and I want to use Preview.app to open and save each file to the same directory.
    Problem is, after each time I save a file, Preview.app doesn't automatically remember/use the last directory where I saved my file(s).
    Forcing me to navigate back to the same directory after each time I save a file; super-annoying.
    But, for some reason, when saving images from the web, Firefox remembers the last directory where I saved the file (jpeg).
    So I'm hoping there's some way, possibly a terminal command to set/force all applications (including Preview.app) to remember/use the directory/path where file(s) were last-saved.
    Anyone?

    Get the third-party utility Default Folder X 4.4.9.

  • Hey,i forgot my login password,so i changed the password by using terminal command(reset password).now i have new user name with new password,but i can't find  my data which i have saved on mac.please help me out in this matter.

    hey,i forgot my login password,so i changed the password by using terminal command(reset password).now i have new user name with new password,
    but i can't find  my data which i have saved on mac.the storage is showing data used and free space on the disk
    please help me out in this matter.

    How did you change your user name?
    resetpassword wouldn't have done it. If you managed to create a new user, then your data is still in the old account.

  • Multiple entries in 'Open Width'using the above terminal command

    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram ework/Support/lsregister -kill -r -domain local -domain system -domain user
    I tried using the above terminal command to reset launch services but it does not seem to work. I still have multiple entries. What am I doing wrong?

    You may have to clarify. Multiple entries in Open With can be normal. For example if you have multiple versions of an application for whatever reason, they will all show. Plus, any applications that report being able to open a file type will show (had an annoyingly long list for text files on my old machine as some apps that didn't even handle documents such as games reported being able to open them).

  • I used a terminal command to show the Library in the User folder, and now the Finder is behaving erractically.  Can anyone tell me how to reverse the show library terminal command?

    I used a terminal command in Lion to show the LIbrary in the Users folder, and now the Finder is behaving erratically, hanging up and becoming almost paralyzed.  Can anyone tell me how to reverse the terminal command for show Library.  The command I used was:
    chflags nohidden ~/Library/

    Showing the Library folder will not cause the problem you've described. Nevertheless:
    chflags hidden ~/Library
    will hide the folder. To reveal the folder:
    chflags nohidden ~/Library
    Note, there is no "/" after Library.

  • I've used a terminal command to change default send keyboard shortcut and now it doesn't work at all!

    My friend provided me with a Terminal command allow me to use Cmd+Enter to send an email (muscle memory from Outlook, hard to forget!)
    Command was:
    defaults write com.apple.mail NSUserKeyEquivalents -dict-add "Send" "@\\U21a9"
    Did that, and it didn't add the Cmd+Enter instruction but removed the Cmd+Shift+D instruction, so I had NO keyboard shortcut. Then Cmd+Enter started working. For a while. Now I'm back to getting the irritating error bleep sound, and having no functional keyboard shortcut for sending mail.
    Does anybody have any advice?

    Try
    defaults delete com.apple.mail NSUserKeyEquivalents
    Then, relaunch Mail.

  • HT2254 is there a way to install mac widget using terminal command?

    Is there a way to download and install mac widget using ther terminal command instead of using widget manager?
    I need to install on a large number of macbooks, this will save me a lot of time...
    Thanks,
    HB

    I am not sure if defaults write will do the install:
    http://ss64.com/osx/defaults.html

Maybe you are looking for

  • CRM BP type Sold-to-party Sales Area Data button not displayed

    Hi Gurus, Currently we are in the system preparation stage, but there's a problem in BP maintenance. For the BP type Sold to Party, the sales area data button is not showing up in the button bar with the General data. I only can see General data and

  • Cannot drop job - says it's running, but it's not

    I did a dbms_scheduler.stop_job (which did not raise any error/warnings), and I killed the database session, but my job is still in user_scheudler_running_jobs view (with null session_id, null cpu_used). When I do a user_scheduler.drop_job, i get an

  • Adobe Bridge CS5 and CS6 need to uninstall

    I have Adobe Bridge CS5 and CS6 that I need to uninstall off my mac I do not have Adobe Uninstall in the Utilities folder. Question how do I uninstall the applications

  • FCPX not saving changes!

    I was working on an hour long standard def show. I had several audio tracks and effects going. I was really happy with the results. After I had made sure the background renders had completed, I close the app. Two days later I opened FCPX and the proj

  • Error Adobe 8.0

    Buenos días, Por cambio de equipo reinstale la licencia de Adobe 8.0 pero al tratar de generar archivos pdf me muestra el error "Faltan archivos PDFMaker Por favor su ayuda puesto que este proceso es parte escencial de mi trabajo diario !!! AYUDA !!!