Open Terminal and Run Commands

Hi I have to ping several IP adresses on a regular basis. Therefore I would like to create an Applescript application that will run terminal and ping the specified IPs so that I can see the results. Any ideas on how to best complete this?

This script will prompt you to enter the number of times you want to ping each server. You'll need to specify the servers to ping in the "set serverAddresses..." line. It writes the results of each ping to a text file on your desktop and opens the file when finished. The next time you run the script if the text file exists it deletes it first.
set theDesktop to (path to desktop)
set serverAddresses to {"www.microsoft.com", "www.apple.com", "www.cnet.com"}
set pingTimes to text returned of (display dialog "Ping each server how many times?" default answer "1" giving up after 10)
tell application "Finder"
if exists file (theDesktop & "ping replies.txt" as string) then
delete file (theDesktop & "ping replies.txt" as string)
end if
set fileID to (open for access file (theDesktop & "ping replies.txt" as string) with write permission)
repeat with aServer in serverAddresses
try
set pingReply to (do shell script "ping -c " & pingTimes & " " & aServer)
on error
set pingReply to "No reply from server " & aServer
end try
write (pingReply & return & return & "########################" & return & return) to fileID
end repeat
close access fileID
open file (theDesktop & "ping replies.txt" as string)
end tell
Robert

Similar Messages

  • Trying to turn off spotlight because it's a resource hog.  open terminal and enter command but it won't respond or even ask for password.

    trying to turn off spotlight because it's a resource hog.  open terminal and enter command but it won't respond or even ask for password.

    Step #1:
    In System Preferences click on Spotlight.
    Step #2:
    Click on the Privacy tab here.
    Step #3:
    Click on the + button here and when the window opens click on "Macintosh HD" (or whatever you've named your HD) and then click the Choose button.

  • Bash script "open terminal and launch command

    I need a script to do this:
    launch a terminal, from this change working directory and then launch a command; the terminal have to remain opened after the command execution.
    Something like:
    $terminal cd $dir && $command
    If I open a terminal and I do:
    cd $dir && $command
    it works
    If I do a .sh script with this:
    xterm -hold -e cd $dir && $command
    or
    terminal -H -x cd $dir && $command
    when I launch it (the script) it doesn't work.
    Last edited by buntolo (2012-01-05 23:44:52)

    karol wrote:
    xterm -hold -e "cd ~/test/ && ls"
    works too.
    I don't know what $command do you mean, but this will list th ~/test directory.
    It works also for me.
    With urxvt and xfce4-terminal don't work.
    But xterm is too minimalist, is there an advanced terminal based on it?
    And I don't unerstand why it doesn't work for xfce4-terminal but for it does for xterm...
    man xfce4-terminal:
    -H, --hold
    Causes the terminal to be kept around after the child command has terminated
    -e, --command=command
    Execute command inside the terminal
    man xterm:
    -hold
    Turn on the hold resource, i.e., xterm will not immediately destroy its window when the shell command completes. It will wait until you use the window manager to destroy/kill the window, or if you use the menu entries that send a signal, e.g., HUP or KILL.
    -e program [ arguments ... ]
    This option specifies the program (and its command line arguments) to be run in the xterm window. It also sets the window title and icon name to be the basename of the program being executed if neither -T nor -n are given on the command line. This must be the last option on the command line.
    What the ...?
    Is only my opinion that there aren't differences between:
    terminal -H -e "cd $dir && $command"
    and
    xterm -hold -e "cd $dir && $command"
    Last edited by buntolo (2012-01-06 13:11:58)

  • [solved] script/keybinding to launch terminal and run command

    the answer is probably simple. but here's the idea.
    i use cmus as my music player. at the moment, i have to open a terminal and then type 'cmus'. i'd like to set up a keybinding to run cmus. (incidentally, i'm trying to do this in i3.)
    the code
    exec cmus
    doesn't work, presumably because 'cmus' has to be loaded from within the terminal. (is that right?) what's the syntax for passing on the command 'cmus' to the terminal? what's the best way to do this?
    Last edited by anti-destin (2012-03-15 23:52:40)

    bindsym mod+c exec urxvtc -name cmus -e cmus
    urxvtc => Your terminal here if you use something else. Most support -name and -e. Please read their man pages.
    -name => Useful for xprop. It assigns the WM_CLASS which can be used for tagging clients.
    man urxvt
    -e command [arguments]
    Run the command with its command-line arguments in the urxvt
    window; also sets the window title and icon name to be the basename
    of the program being executed if neither -title (-T) nor -n are
    given on the command line. If this option is used, it must be the
    last on the command-line. If there is no -e option then the default
    is to run the program specified by the SHELL environment variable
    or, failing that, sh(1).
    Last edited by Earnestly (2012-03-15 19:19:25)

  • [solved] rox run action - open xterm and run command?

    Probably a really simple question but I'm not having any luck.
    I want to set a run action in rox for mp3 files to bring up xterm and run mpg123 in it. I've tried pipes and redirects but they don't work. Any ideas?

    You're welcome

  • How to "telnet" and run commands on another computer?

    I have a Unix program. I need this to "telnet" to a Windows computer and run commands (via the prompt in Windows). Is there a way to do this in java?
    Also it is something that will be a cron job so the password will be stored in a file rather than the user typing it at the screen. There is no GUI. There is no server or java process running on Windows at the time. The Unix program needs to connect to Windows only when needed.

    Try enabling the Windows telnet server, use a regular telnet client and check if it is enough for your needs.
    Several commands in Windows apparently could be run in command-line mode using telnet, but for some reason they don't work very well. For instance, they could be using some special console-mode APIs for hiding the cursor or drawing characters in different colors, that simply will not be echoed by the telnet server.
    I remember when I've tried to use the osql tool (a command-line interface) of MS SQL Server in a Windows telnet server session. Some things simply didn't work.

  • You've introduced TABS but I discovered by opening Yahoo and running a video that it continues when I open a new tab! Not good. Have I missed a setting or ???

    You've introduced TABS but I discovered by opening Yahoo and running a video that it continues when I open a new tab! Not good. Have I missed a setting or ??? This may be just the way it is but it somewhat defeats the ease of going to a often used web site using tabs.

    So, you are meaning that if you have a video running in one tab, then go to another, the video continues to run? yes, that is normal behavior.
    Tabs are basically having like multiple windows inside one main window. It is just as if you opened a video in a window, started it playing, then opened a new window, the video would still play.
    Or am I misunderstanding your question?

  • How to using sqlplus to connect and run command ?

    Hello,i have a small problem please help me
    I want to use sqlplus to connect and run command
    for example : sqlplus test/test@DB select sysdate from dual ;
    and then it will show data (sysdate) to screen
    what should i do ?
    Thanks

    kenshin19xx wrote:
    Hello,i have a small problem please help me
    I want to use sqlplus to connect and run command
    for example : sqlplus test/test@DB select sysdate from dual ;
    and then it will show data (sysdate) to screen
    what should i do ?
    Thanks
    bcm@bcm-laptop:~$ echo "select sysdate from dual ;" > now.sql
    bcm@bcm-laptop:~$ sqlplus user1/user1 @now
    SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 14 20:41:33 2011
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SYSDATE
    2011-12-14 20:41:33

  • Shell Script - Need to Open terminal and Print output?

    Hi All,
    I have a script to update a git version of a software, but I would like to be able to check the output of the script in a terminal.
    So in a nut shell, I want when launching the script:
    - Terminal to Open
    - All command to be executed in the terminal
    - Terminal to close only if no error (do not know if it's possible?)
    See below my very simple script:
    Many thanks in advance for your time and advice,
    rm -r /home/sweetth/banshee &&
    cd /home/sweetth &&
    git clone git://git.gnome.org/banshee &&
    cd /home/sweetth/banshee &&
    ./autogen.sh &&
    make

    Right,  I manage it differently
    So I got my script to dl those PKGBUILD for those Ipod library needed for the latest Banshee, then dl the latest banshee git and "make" it.
    for those who might be interested to keep their banshee-git update:
    #!/bin/bash
    xterm -hold -e "mkdir ~/libpod;
    cd ~/libpod;
    mkdir ~/libpod/gtk-sharp-beans-git
    cd ~/libpod/gtk-sharp-beans-git
    wget http://aur.archlinux.org/packages/gtk-sharp-beans-git/gtk-sharp-beans-git/PKGBUILD;
    wget http://aur.archlinux.org/packages/gtk-sharp-beans-git/gtk-sharp-beans-git/autogen_fix.patch;
    makepkg -s;
    mv gtk-sharp-beans-git** ~/libpod;
    cd ~/libpod;
    rm -rf ~/libpod/gtk-sharp-beans-git;
    mkdir ~/libpod/gio-sharp-git;
    cd ~/libpod/gio-sharp-git;
    wget http://aur.archlinux.org/packages/gio-sharp-git/gio-sharp-git/PKGBUILD;
    makepkg -s;
    mv gio-sharp-git** ~/libpod;
    cd ~/libpod;
    rm -rf ~/libpod/gio-sharp-git;
    mkdir ~/libpod/gkeyfile-sharp-git;
    cd ~/libpod/gkeyfile-sharp-git;
    wget http://aur.archlinux.org/packages/gkeyfile-sharp-git/gkeyfile-sharp-git/PKGBUILD;
    makepkg -s;
    mv gkeyfile-sharp-git** ~/libpod;
    cd ~/libpod;
    rm -rf ~/libpod/gkeyfile-sharp-git;
    mkdir ~/libpod/gudev-sharp-git;
    cd ~/libpod/gudev-sharp-git;
    wget http://aur.archlinux.org/packages/gudev-sharp-git/gudev-sharp-git/PKGBUILD;
    makepkg -s;
    mv gudev-sharp-git** ~/libpod;
    cd ~/libpod;
    rm -rf ~/libpod/gudev-sharp-git;
    mkdir ~/libpod/libpod-sharp-git;
    cd ~/libpod/libpod-sharp-git;
    wget http://aur.archlinux.org/packages/libgpod-sharp-git/libgpod-sharp-git/PKGBUILD;
    makepkg -s;
    mv libgpod-sharp-git** ~/libpod;
    rm -rf ~/libpod/libpod-sharp-git;
    cd ~/libpod;
    sudo pacman -U gtk-sharp-beans-git** gio-sharp-git** gkeyfile-sharp-git** gudev-sharp-git** libgpod-sharp-git**;
    rm -rf ~/banshee;
    cd ~;
    git clone git://git.gnome.org/banshee;
    cd ~/banshee;
    ./autogen.sh;
    make;
    rm bin/Banshee.NotificationArea.dll*"

  • Terminal not running commands.

    I recently tried running a command to uninstall Xcode "sudo /Developer/Library/uninstall-devtools –mode=all" but it failed after asking me to enter a password. Now after I run the Terminal I get nothing for a response and the window is now named "Terminal-login-86x24". I looked for everything online and on Apple support. What should I do?

    paniclabs wrote:
    I recently tried running a command to uninstall Xcode "sudo /Developer/Library/uninstall-devtools –mode=all" but it failed after asking me to enter a password. Now after I run the Terminal I get nothing for a response and the window is now named "Terminal-login-86x24". I looked for everything online and on Apple support. What should I do?
    That command looks incomplete. From the readme:
    ++++++++
    Uninstalling Xcode Developer Tools
    To uninstall Xcode developer tools on the boot volume along with the <Xcode> directory, from a Terminal window type:
    $ sudo <Xcode>/Library/uninstall-devtools --mode=all
    To remove the underlying developer content on the boot volume, but leave the <Xcode> directory and supporting files untouched, from a Terminal window type:
    $ sudo <Xcode>/Library/uninstall-devtools --mode=systemsupport
    To just remove the UNIX development support on the boot volume, but leave the <Xcode> directory and supporting files untouched, from a Terminal window type:
    $ sudo <Xcode>/Library/uninstall-devtools --mode=unixdev
    Finally, to just uninstall the <Xcode> directory you can simply drag it to the trash, or from a Terminal window type:
    $ sudo <Xcode>/Library/uninstall-devtools --mode=xcodedir
    NOTE: The uninstaller that ships with previous versions of the Xcode developer tools will not clean everything off of your system properly. You should use the one installed with these Xcode developer tools.

  • Why does InDesign freeze when I open it and run slowly?

    I've been having problems with InDesign ever since I got CS5, and it's at the point where I can't even do simple projects. Every time I open InDesign, it freezes. I can't click anything in the program and it won't even minimize or close. The only way to close it is from the Task Manager. Nothing else works. On the rare occasion that it does work (after waiting about five minutes for it to un-freeze), it takes a long time to open any file, even really small ones. When they do open, it freezes for about a minute any time I try to move something, change text, change colors, or pretty much change anything. This is the case even on one-page documents with minimal text and a few images. The only thing that isn't slow is exporting PDFs.
    At first I thought that it was just slow when I also had Photoshop open, but that's not the case because it still performs slowly and freezes all the time when the only other program I have open is Outlook.
    I really appreciate the help... I can't even do any work right now and I'm running out of time.
    Windows 7 Professional
    Processor: Intel(R) Core(TM)2 Duo CPU
    RAM: 4GB
    InDesign version 7.0.3
    Let me know if you need to know any more specs... I apologize, I really have no idea what you need to know.
    Thank you so much!!!

    The DPI is at the default setting, so that's not it. I'm going to disable Aero and see if that works, but its hard to tell right away because sometimes it does work. I don't know if that could really be causing it though because it's not just clicking that's not working. It's bascially like the InDesign interface becomes my desktop background. It doesn't close or minimize and I can't interact with it at all.
    I will see how it behaves today with Aero disabled. Thank you for the tip!

  • [SOLVED] Opening Shell and runnning command(s)

    Hi,
    I have just discovered the wonderful program xbindkeys, and am thus setting all my keybindings.  I ran into a problem when I came to adding the music keybinding [EDIT].  I don't use a gui, just command line mplayer, so this is a bit problematic, as I want to be able to launch a shell and then run a command inside that shell (in this case cd /home/jhl/music/mplaylist && mplayer *).  So when I try :
    konsole -e cd /home/jhl/music/myplaylist && mplayer *
    It does not do what I expected .  I've looked around here and on google for an answer, but have yet to find one. 
    All help is greatly appreciated .
    -Josh
    Last edited by luskjh (2009-07-12 17:00:12)

    Crouse's method worked (thanks crouse )
    And the [EDIT] was because I repeated 'adding the music keybindings' twice, and didn't catch it when reviewing the thread, opps .
    Thanks for all the help .
    -Josh

  • I had a virus and can run no exe files... I tried to DL new firefox and did with Internet explorer but can't open it and run it tried to run a registry repair program can't won't open Help???

    I had the XP Security Alert virus... or what ever it was called. I DL a new Avast program and it helped get rid of it. Since I can not open exe files. I save the firefox file, go to the temp file and it can't open it I have no tech support can you help or tell me who to go to for help????

    Startup - Gray, Blue or White screen at boot, w/spinner/progress bar
    Startup Issues - Resolve
    Startup Issues - Resolve (2)
    Avast! Uninstall

  • Using Automater to run Terminal and enter a command

    I am currently interested in using a script or the automator to open Terminal and enter a specific command line I use to authenticate on my university network. Frankly I'm getting tired of typing that command line in so often.
    However, I am relatively new to apple, and I'm not very familiar with scripting. If someone could give some suggestions that would be great.

    Open the Script Editor in the /Applications/AppleScript/ folder and type in the following:
    do shell script "your command"
    Save this script as an application and place it on the desktop for easy access. If the command requires the use of sudo, the needed syntax is:
    do shell script "your command" password "yourpass" with administrator privileges
    The actual phrase 'sudo ' isn't necessary in do shell script unless you will be passing sudo a flag. If the command needs interaction, use the following:
    tell application "Terminal"
    do script "your command"
    end tell
    This implementation requires the use of sudo for root authentication.
    (20272)

  • Nautilus-open-terminal no longer opens non-default terminal

    I'm running gnome and have had working for some time now nautilus-open-terminal, with it set to open terminator instead of gnome-terminal. Yesterday I upgrade nautilus-open-terminal.
    [2013-03-03 10:40] upgraded nautilus-open-terminal (0.19-3 -> 0.20-1)
    Now it is opening gnome-terminal instead of terminator. I've tried a few things to fix this. The first was how I initially set terminator to open, by opening dconf-editor and navigating to org.gnome.desktop.applications.terminal and setting exec to terminator. This was already set, so I tried setting it to default and resetting it. No luck.
    I also tried setting it via gsettings with:
    gsettings set org.gnome.desktop.default-applications.terminal exec /usr/bin/terminator
    I still get gnome-terminal and not terminator. Is there some way in which the newer version looks for which terminal to open that is now different than before? I suppose I could roll back that upgrade and see if that fixes things, but I was curious if anyone knew what was happening here.
    Thanks,
    -Koopa
    Last edited by Koopa (2013-03-05 00:17:29)

    Hi Koopa.
    Unfortunately, there's not much you can do about that. Only solution now would be to patch GLib itself.
    The "guilties" here are the commit below in nautilus-open-terminal and glib itself.
    commit ce56165ed58b225804f50a01dc101097b7892efd
    Author: Kalev Lember <[email protected]>
    Date:   Wed Feb 27 21:05:47 2013 +0100
        Port the terminal launching to GAppInfo
        ... dropping the use of eel-gnome-extensions and libgnome-desktop.
        This fixes the build with libgnome-desktop 3.7.90 where the terminal
        launching functionality was dropped. Instead, we use GAppInfo with the
        G_APP_INFO_CREATE_NEEDS_TERMINAL flag as a replacement.
    In Glib, the code that prepends the terminal command  line is in function prepend_terminal_to_vector on file gio/gdesktopappinfo.c. And as you can see, there is no terminator there.
    check = g_find_program_in_path ("gnome-terminal");
    if (check != NULL)
    term_argv[0] = check;
    /* Note that gnome-terminal takes -x and
    * as -e in gnome-terminal is broken we use that. */
    term_argv[1] = g_strdup ("-x");
    else
    if (check == NULL)
    check = g_find_program_in_path ("nxterm");
    if (check == NULL)
    check = g_find_program_in_path ("color-xterm");
    if (check == NULL)
    check = g_find_program_in_path ("rxvt");
    if (check == NULL)
    check = g_find_program_in_path ("xterm");
    if (check == NULL)
    check = g_find_program_in_path ("dtterm");
    if (check == NULL)
    check = g_strdup ("xterm");
    g_warning ("couldn't find a terminal, falling back to xterm");
    term_argv[0] = check;
    term_argv[1] = g_strdup ("-e");
    Me too, this bugs me a lot.
    If I wasn't too busy with another project, I would try to submit a proposal to freedesktop.org to "standardize" a way to find the default terminal, hoping that gnome devs would consider to implement it.

Maybe you are looking for

  • Windows 7, no VoiceFX Changer?

    Windows 7, no VoiceFX Changer?I no longer have the tab to change my voice with the voice effects... cant find it anywhere in the control panel. Is this unique, or are many of you experiencing this as well? Other than that, I have the well documented

  • Movement Type 511 when  stock in the Inventory is nil

    Hello Sir / Madam  , I have some queries regarding 511 Movement type : Free-of-charge delivery from vendor. When this movement type is posted it updates the Stock (MARD-LABST) as well as the Valuation Table (MBEW-LBKUM). (Unrestricted movement) But t

  • Camera Roll Trouble

    OK, so when I go to the photos app on my iPhone 3GS, and I tap Camera Roll, only about half of my pictures show up. The rest are simply black thumbnails. However, when I tap on one, the picture shows up full screen. This is really annoying, and I wou

  • Streaming Video Usually Fails

    Using latest Safari, many TV station websites offering live video, simply do not run videos. Sometimes there is an error msg re "tmp file"; sometimes not. Often, msg states that the video stream does not support Safari, but if I change how I open tha

  • Manual API Documentation update

    Hi, I'm not sure if this the right location to post my concern, anyway, I just installed the xcode4(downloaded from internet cafe that has fast connection) and then I want to install/update the iOS4... library. but the problem is my internet connecti