Running shell script at startup (before login)

Objective: on the Mac side of a dual-boot Intel, I want to automate running a shell script at startup that will unmount the "Untitled" Windows partition. As a single line command, the following runs correctly when invoked manually from Terminal:
/usr/sbin/diskutil unmount force disk0s3
How can I include this script in the startup sequence?

V.K. asks: "why do you need to do this before login?" And macwiz1220 suggests including in Login Items an app created by AppleScript that launches Terminal and runs the diskutil command.
When I create and run such an app at login, I encounter problems with Terminal, which is why I thought to run an .sh script at startup. But if we can debug the problems with Terminal, then I won't have to venture into the more complex solutions offered by gbullman and Barney-15E. Terminal problems:
(1) When Terminal prefs for Settings>Shell are set this way:
(a) When the shell exits: Close the window.
(b) Prompt before closing: Never
then the result is: Terminal is launched and exits quickly, but the "Untitled" volume is not unmounted.
(2) When Terminal prefs for Settings>Shell are set this way:
(a) When the shell exits: Close the window if the shell exited cleanly
(b) Prompt before closing: Never
then again the result is: Terminal is launched and exits quickly, but the "Untitled" volume is not unmounted.
(3) When Terminal prefs for Settings>Shell are set this way:
(a) When the shell exits: Don't close the window
(b) Prompt before closing: Always
then after invoking the script, Terminal properly unmounts "Untitled" and presents a dialog: "You have 2 windows with running processes. Do you want to review these windows before quitting?" Here are the two Terminal windows:
an echo of the cmd "/usr/sbin/diskutil unmount force disk0s3" followed by a report on return: "Volume on disk0s3 force unmounted." I don't want the user to have to see this and close the window.
(ii) a fresh Terminal session, no commands entered. I also don't want the user to have to deal with this.
How can I get Terminal to properly unmount the object, and shut down without demanding user interaction?
P.S. what is an O.P.?

Similar Messages

  • Automator runs shell script differently

    hi
    i build a little shell script that mounts my network-shares when they are available - that's works perfect if run by terminal but if i run it via Automator-Run shell script it does ******** - it doesn't seem to recognize my variables and creates dirs like $“Data“  instead of just Data
    can anyone help me with that?
    #!/bin/bash
    # connects to network shares if server available
    #config - wich server and mountpoints, login
    server=$"192.168.2.1"
    serverName=$"NAS(AFP)"
    dir=$“Data“
    dir2=$“Data1“
    login=$“xxx“
    pw=$“xxx“
    #connect-test and create mountfolders
    ping -q -c3 $server > /dev/null
    if [ $? -eq 0 ];then
      if [ -d "/Volumes/"$dir"" ]; then
      echo "folder $dir exists"
      else
      echo "creating folder $dir"
      mkdir "/Volumes/"$dir""
      fi
      if [ -d "/Volumes/"$dir2"" ]; then
      echo "folder $dir2 exists"
      else
      echo "creating folder $dir2"
      mkdir "/Volumes/"$dir2""
      fi
    #mount
      mount_afp "afp://"$login":"$pw"@"$serverName"._afpovertcp._tcp.local/"$dir"" "/Volumes/"$dir""
      mount_afp "afp://"$login":"$pw"@"$serverName"._afpovertcp._tcp.local/"$dir2"" "/Volumes/"$dir2""
      echo „ping ok“
    else
      echo „failed to connect to $serverName“
    fi

    FYI.  If you create an Alias of a mounted volume, the Alias will record all the connection information, except the password.  If your keychain is not locked, then when double clicking on the Alias, it will get the password from the keychain and mount the networked volumes (assumes you allowed the password to be stored in the keychain when you first mounted the volumes interactively).
    The Aliases can be put into your System Preferences -> Users & Groups -> Startup Items if you like.
    If this is a laptop and you are re-mounting the volumes when you get to a specific location, you might want to look at ControlPlane
    <http://www.macupdate.com/app/mac/39644/controlplane>

  • Shell Script  for Startup and Shutdown the database

    Hi,
    i want Shell Script for Startup and Shutdown the database in Solaries.
    could any one can hep me where i can get this script. or send to me to [email protected]
    Thanks & Regards,
    Gangi reddy

    SHUTDOWN
    SHUTDOWN ABORT]
    Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
    Terms
    Refer to the following list for a description of each term or clause:
    ABORT
    Proceeds with the fastest possible shutdown of the database without waiting for calls to complete or users to disconnect.
    Uncommitted transactions are not rolled back. Client SQL statements currently being processed are terminated. All users currently connected to the database are implicitly disconnected and the next database startup will require instance recovery.
    You must use this option if a background process terminates abnormally.
    IMMEDIATE
    Does not wait for current calls to complete or users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    NORMAL
    NORMAL is the default option which waits for users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    TRANSACTIONAL [LOCAL]
    Performs a planned shutdown of an instance while allowing active transactions to complete first. It prevents clients from losing work without requiring all users to log off.
    No client can start a new transaction on this instance. Attempting to start a new transaction results in disconnection. After completion of all transactions, any client still connected to the instance is disconnected. Now the instance shuts down just as it would if a SHUTDOWN IMMEDIATE statement was submitted. The next startup of the database will not require any instance recovery procedures.
    The LOCAL mode specifies a transactional shutdown on the local instance only, so that it only waits on local transactions to complete, not all transactions. This is useful, for example, for scheduled outage maintenance.
    Usage
    SHUTDOWN with no arguments is equivalent to SHUTDOWN NORMAL.
    You must be connected to a database as SYSOPER, or SYSDBA. You cannot connect via a multi-threaded server. For more information about connecting to a database, see the CONNECT command earlier in this chapter.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013607
    Joel Pérez

  • Trouble using Run Shell Script with python in Automator

    Hi. I have a python script I want to run in Automator (update_puzzles.py). All it does is check, rearrange and update files and there is not supposed to be any input. I can get the script to run outside of Automator, in Terminal, by navigating to the right directory and typing "python update_puzzles.py"
    I must not be setting up Run Shell Script correctly. I have it set to /bin/bash and Pass Input to stdin. The command line simply reads python /pathname/update_puzzles.py (where pathname is the path to the .py file, which I got by dragging the file onto the Run Shell Script command window). There are no actions before this in my workflow and the action after is View Results.
    The log says Run Shell Script failed, and the error is "Traceback (most recent call last):"
    Any suggestions?
    Thanks so much.

    If the script is expecting to do stuff with files in the same directory as the executable, you will probably need to add a statement to change to the appropriate working directory. The shell used in the Automator *Run Shell Script* action is a generic one that does not share any of the environment variables that the Terminal uses.

  • Cannot add "Run shell script" to workflow

    Just like the subject says on an iBook G4, OS X 10.4.8. The previous solution of deleting the Automator cache file in ~/Library did not work for me. The console log does show an error when I attempt to drag Run Shell Script to the workflow error:
    2006-11-25 21:15:32.909 Automator[545] * -[NSTextView replaceCharactersInRange:withString:]: nil NSString given.
    I do have an updated bash installed using DarwinPorts, however that is installed to /opt/local/bin, which appears in my path before /usr/bin. This isn't causing problems on my cube, though.
    Any ideas?

    You might have a corrupted file in the action, in which case you could reload it with something like Pacifist. You can't get the digest of a directory, so for comparison, compressing a copy of /System/Library/Automator/Run Shell Script.action on my desktop gives me the following:
    sha1 digest: c209b69777f6a3301d72ddf0eb0ad4e7d4230741
    md5 digest: 09e4ade9056ada3294ffb93bd16de1a7

  • Running shell scripts from within oracle. A big task is forgotten

    Dear List,
    I have some shell shell scripts which do some tasks on the linux OS level.
    I am calling the Korn scripts using a java class, which in turn is being called from a PLSQL function.
    All but one of the 10 script works fine. This is the script which does the most work, and takes on average 40 minutes usually.
    Why does Oracle forget the running of the shell script? I wait in my PLSQL function for the return code, but it never comes. The scripts I have not written myself !
    I look forward to your reply on this matter.
    regards
    Ben

    Hi
    If you are using the Oracle database 10g, the new dbms_scheduler package allows you to run shell scripts. The dbms_scheduler.create_job procedure have one parameter called the job_action in which you specify the full path of the shell script.
    I hope this will help

  • How to run shell script using External Process in Process Flow?

    Hi,
    We can run external process using Process flow.
    I would like to run shell script as external process in Process flow.
    Could any one please explain it?
    Thanks and regards
    Gowtham Sen.

    HI,
    As you said I tried this case. I got the following error. The script is running successfully while I tested at unix command prompt.
    The error is as follows..
    tarting Execution PFPS_SMPL_RUNSHELL
    Starting Task PFPS_SMPL_RUNSHELL
    Starting Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS
    /SOURCE_FILES/CollectFiles.sh: line 1: ls: command not found
    /SOURCE_FILES/CollectFiles.sh: line 1: wc: command not found
    /SOURCE_FILES/CollectFiles.sh: line 1: ls: command not found
    Completing Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS
    Starting Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS_1
    SQL*Plus: Release 10.1.0.2.0 - Production on Fri Sep 29 22:57:39 2006
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    ERROR:
    ORA-12545: Connect failed because target host or object does not exist
    Enter user-name: SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_identifier>] | /
    Enter user-name: SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_identifier>] | /
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    Completing Task PFPS_SMPL_RUNSHELL:EXTERNALPROCESS_1
    Completing Task PFPS_SMPL_RUNSHELL
    Completing Execution PFPS_SMPL_RUNSHELL
    My scenario is---
    I am trying to return a file name from one shell script. I created a external process for that. After completion of this process, I am running another script which takes that file name and trying to create a external table. The both scripts are runnning successfully. But while I am trying to run using process flow, its not coming.
    And I am not getting the way to catch the output of external process and pass it as parameter as another external process.
    Any suggestions are welcome.
    Thanks and regards
    Gowtham Sen.

  • How to pass video file name to run shell script

    Trying to make an automator script that will 1. Start a video capture, 2. Stop video capture, 3. Rename video, 4. Run Shell Script. Here is the shell script:
    for f in "$@"
    do
    echo "$f"
    /usr/bin/podcast --server my.podcast.server --user myself --pass mypass --submit --file $f --workflow "my workflow" --metadata /path/to/file
    done
    Question:
    Do I need to create a variable in the automator script to pass it to the script? If I need the variable do I also need to use both Set Value of Variable and Get Value of Variable? If I don't need a variable does $f need quotes around them?

    I'm not familiar with the terminal command /usr/bin/podcast so I don't know what it does but what i said is correct. to pass a file to this action you don't need any variables. the previous action in the workflow should output the video file you want to process, that's all. how you arrange that is up to you. it's clear that you have to fill in appropriate things in that shell script like " my workflow" and path to metadata. But if you have questions about how this shell action works you should ask people who made it.

  • Pass multiple Automator variables to Run Shell Script?

    I have two Automator variables I'd like to pass to Run Shell Script. I'm missing something obvious, but how is this done?
    Thanks in advance

    i don't know a nice way to do it but in general any input passed to a shell script will be stored in $@ if input is passed as arguments.
    in particular, if you stack two "get value of variable actions" one after another and follow it by "run shell script" both variables will be stored in $@ as a list. just try it out with the default
    for f in "$@"
    do
    echo "$f"
    done
    You'll see that both variables will be echoed.

  • Running Shell Script

    Hi all,
    I need to run shell script on one of linux servers while executing some IdM workflow.
    There is no need to manage that server/ provision accounts / reset passwords etc but just to run the script and to process the result.
    I have IdM 8.04 installed on Windows Machine.
    What are my options to achieve that mission?
    Thank You,
    Alex.

    I was considering a situation similar to AD after actions where sometimes we execute a dos batch file for any specific purpose like creating home folder using mkdir. I was thinking on similar lines if your shell script is also for a specifc function similar to the one I mentioned above and if it is applicable in windows environment, you might covert that into a dos batch and do similar to an after action.
    Since you need your shell script to be run in UNIX / LINUX machine, I do not see any other way other than writing a java class and invoke within a wf as it was mentioned by etech or if you are planning on using any of the out of the box resource adapters, the AIX resource adapter reference might help, but I have not worked with that

  • Automator and "Run Shell Script" error

    First, if I'm in the wrong place with this- sorry. Figured this was an OS kind-of thing.
    I recently migrated to a new iMac ... I brought along an Automator script; I've been using it for years to perform a little rsync backup to an USB HDD. It's 'never' given me any problems ... until now!
    "*Run Shell Script*" encountered an error .. but alas, the system log is devoid of messages ... and the verbose log I have running indicates that all the files are copied/backed-up ... I would love any input on this that might help me get back on the feet. .....
    *Here's what my Shell Script Looks like:*
    Shell Option: /bin/bash
    Pass Input: to stdin
    rm -dfr '/Volumes/Backup HD/*********'
    rm -dfr '/Users/***********/Library/Logs/Profile_Backup.log'
    rsync -rltv /Users/******** '/Volumes/Backup HD/' > /Users/*******/Library/Logs/Profile_Backup.log
    (I'm sure there's way to only sync the changed stuff between backups ... but I've simply preferred the fresh copy approach).
    *I do however note this in my logs when I open Automator:*
    12/14/10 3:15:46 PM [0x0-0x42042].com.apple.automator.Backup[464] Application Stub: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

    @Tony T1
    Thanks, I'll certainly adjust the log file as suggested
    In troubleshooting the problem I went the terminal route - and issued each command ... during the rsync process I was getting an error ... turns out when it was syncing the SyncServices folder it was encountering a copy of the keychain ... which had root permissions - naturally rsync was not able to copy the file (personally I have no idea why the keychain would be being sync'd with anything)!
    I removed the file from the sync ... I'm still doing some "debugging" to correct the problem-
    Again, thanks for the assist!

  • Automator - Run Shell Script - Does not return when script launches firefox

    Automator does not work the same on my MacBooks as my Mac mini! Both are latest Snow Leopard. I'm trying to automatically setup my MacBook after it decides if I'm at work, or elsewhere.
    The Automator Action "Run Shell Script" (Shell: /usr/bin/perl) does NOT return control when attempting to launch Firefox:
    system("/Application/Firefix.app/Contents/MacOS/firefox-bin -private news.google.com &");
    Note: the ampersand should cause Firefox to start as a background process.
    It only returns control after I close Firefox. I have a "Show Growl Notification" as the second action, so I know that the first action has not completed. Odd thing is that this works on my Mac mini. I also noticed that another difference: on my MacBook status is displayed in the top toolbar when the Automator application is running.
    Any ideas?

    Thanks, it worked. I forgot about stderr and stdin.
    I'm using Perl as it is part of a bigger script. I can quickly and easily figure out if I am at work where my MacBook is plugged into a network:
    my $ethernet = qx(ifconfig en0) =~ m{status:.active}xms;
    if ($ethernet) {
    # setup stuff for work environment
    } else {
    # setup stuff for mobile environment
    }

  • Run shell script as sudo user without giving sudo passowrd from normal usr

    Hi ,
    i am running shell script from my account with sudo user what is the problem in my procedure.
    Please if any thing wrong in my procedureprocedure or any permission required please let me know.
    here is the my procedure and sudo permissions.
    [techm@ppsol04 ~]$ sudo su - dadm sudo -u dadm /u01/ora/tools/Dbmon/scripts/export.sh
    Sorry, user techm is not allowed to execute '/u01/ora/tools/Dbmon/scripts/export.sh' as dadm on ppsol04.
    [dchandu@ppsol04 ~]$ sudo -l
    Matching Defaults entries for techm on this host:
    env_keep=SSH_AUTH_SOCK, !authenticate, env_reset, always_set_home, !requiretty
    sudo permissions :
    sudo -l
    Matching Defaults entries for techm on this host:
    env_keep=SSH_AUTH_SOCK, !authenticate, env_reset, always_set_home, !requiretty
    User techm may run the following commands on this host:
    (ALL) NOPASSWD: /local/bin/hardened_profile.sh
    (root) NOPASSWD: /bin/su - dora
    (root) NOPASSWD: /bin/su - doraadm
    (root) NOPASSWD: /bin/su - docenter
    (root) NOPASSWD: /bin/su - tora
    (root) NOPASSWD: /bin/su - toraadm
    (root) NOPASSWD: /bin/su - tocenter
    (root) NOPASSWD: /bin/su - hora
    (root) NOPASSWD: /bin/su - horaadm
    (root) NOPASSWD: /bin/su - hocenter
    (root) NOPASSWD: /bin/su - agcfdwf4
    (root) NOPASSWD: /bin/su - pora
    (root) NOPASSWD: /bin/su - dadm
    (root) NOPASSWD: /bin/su - pocenter
    (root) NOPASSWD: /bin/su - agcfdwp4
    Thanks
    tech

    Can you please explain what you are trying to accomplish?
    To my understanding there is no such thing like a sudo password for a normal user. Sudo allows users to become root based on a sudo list (suoders). The user is then prompted for their own account password to run as super-user or root.

  • Can't add "Run Shell Script" in Automator

    When I drag "Run Shell Script" to the right pane in Automator nothing happens. All other applications I've tried can be dragged to the right pane. In the system.log I can find the following message:
    Feb  7 16:56:48 Bananaboat Automator[195]: Error : -[AMWorkflowView _addAction:Kör kommandotolksskript] : * -[NSTextView replaceCharactersInRange:withString:]: nil NSString given.
    "Kör kommandotolksskript" is "Run Shell Script" in Swedish.
    Any ideas how to fix this?

    You might have a corrupted file in the action, in which case you could reload it with something like Pacifist. You can't get the digest of a directory, so for comparison, compressing a copy of /System/Library/Automator/Run Shell Script.action on my desktop gives me the following:
    sha1 digest: c209b69777f6a3301d72ddf0eb0ad4e7d4230741
    md5 digest: 09e4ade9056ada3294ffb93bd16de1a7

  • Run Shell Script

    Hi,
    I'm new to Automator so I don't really know what to do:
    What I want to do is run this line and create an "application" for my dock
    virtuoso-t -f -c /usr/local/var/lib/virtuoso/ontowiki/virtuoso.ini &
    so I choose "Run Shell Script" Workflow in the Automator Menu. Set the Shell to /bin/zsh (that's what im using) pass input: to stdin.
    The workflow runs with no errors, but the virtuoso server does not start
    any ideas?
    Thanks daniel

    The shell used doesn't have any of your environment variables (it is just a generic shell with no custom settings), so if virtuoso isn't in the standard path it won't be found. It is usually a good idea to use full paths anyway, especially when using Automator's Run Shell Script or AppleScript's do shell script. I am also going to guess that the missing space between the -t option is a typo.

Maybe you are looking for

  • Apple Mail Client - No Messages in Sent Mailbox

    I am using the Apple Mail client with Yahoo! IMAP. For some reason, sent messages no longer appear in the Sent Mailbox. Why is that?

  • Oracle Discover Viewer running problem

    Hai Friends... When i am running Discover Viewer i got error message saying that ,Communication Error or ORB intrnal error. I wouid appreciate any help. Cheers Gopi

  • How do I delete the "other" memory from my Iphone 4?

    Most of the memory on my phone is taken by music, but the "other" memory is getting annoying. It takes up 1.34GB and i want to delete it. can anyone help me?

  • How do you change the pictures in your slideshow?

    I am setting up a slideshow where I will update the pictures as new projects are completed.  I cannot seem to remove old pictures to install new ones.

  • Where is my free album art?

    Steve Jobs said in his September 2006 conference that all new iTunes account holders would receive the album artwork to the songs already in their music library. I just signed up for an account today and would like to know how to do this. Can anyone