How do I run a bash script *before* login?

I've got a bash script that opens an SSH tunnel that I'd like to run (as root) before any user logs in. How do I go about getting this script to run between boot and user login?
Thanks.

Post Unix queries to the Unix forum under OS X Technologies where those mavens frolic.

Similar Messages

  • How can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path?
    Is there some way I can set a "Working folder" in SQL Plus??
    Thanks!
    Tom

    You can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
    scripts.
    I would like to use another directory than the oracle/bin...
    How can I do this ??
    Hello,
    U can do this by this way:
    Save odm_script.sql file to the default Oracle
    directory i.e. Oracle-Home/bin and Run following command
    through SQL Plus.
    SQL>@Script_Name
    I hope this will resolve ur problem.
    Regards,
    Omer Saeed Khan.

  • How can I execute a bash script by double clicking in finder

    Hello!
    How can I execute a bash script using finder? Or better: How can I create an alias, which executes my bash script?
    Thanks Johann

    Add the suffix command in your script name. E.g. Script.command.

  • Can you run a bash script on boot in single user mode

    Hey guys quick question.
    Is it possible to run a bash script on boot in single user mode.
    I can create a file and dump it on the root hd.
    Let's call it repair.
    I can then boot to single user mode and run it by typing /repair.
    But I want it to do it automatically.
    Every time I go into my machines that I clean for my job. I have to run sbin/fsck -fy
    Then I have to mount the drive and then remove all cache files, then reboot the machines.
    I would like to automate this by just holding command s and then moving to the next computer.
    There must be some sort of boot daemon somewhere.
    Please help.
    Sincerely,
    John

    Have you seen Applejack?
    http://applejack.sourceforge.net/
    It doesn't start automtically, but does cleanup.
    Robert

  • How do I run a vb script in Windows Server 2008 R2

    Hello,
    How do I run a vb script
    to generate an OID to create a new element
    of a schema in an active directory
     in Windows Server 2008 R2?
    Thank you for your feedback.
    Juan Carlos
    Juan Carlos

    Hello,
    How do I run a vb script
    to generate an OID to create a new element
    of a schema in an active directory
     in Windows Server 2008 R2?
    Thank you for your feedback.
    Do you have the script yourself? Assuming yes, it is the command:
    cscript YourScript.vbs
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?

  • How do I save a "bash" script? (in attempt to fix one of my other problems)

    Here is my original problem:
    http://discussions.apple.com/thread.jspa?threadID=2195627&tstart=0
    I came across this that sounds like it will help my issue:
    http://www.macosxhints.com/article.php?story=20090316190817357
    However, what am I supposed to do with that code? Put it in the Terminal? Save it as an Apple Script? I also got the "lingon" program set up, all I need to do is figure how how to save this "bash" script and all set!
    Any ideas?
    -Scott

    This link might help as it shows how to create the plist using lingon:
    http://mymacfixes.blogspot.com/2009/06/how-do-i-stop-clicking-noise-from-hard.ht ml

  • How do I run a shell script via AppleScript?

    Seems obvious, "do shell script" but that doesn't work for me.
    I have an Automator app which runs a shell script, I'd like to take that into an AppleScript. My AS doesn't run the shell script. Perhaps "do shell script' is expecting the script to be located elsewhere? The rest of my AS runs fine, but the shell script doesn't.
    repeat with i from 1 to count of items in exportFolder
      do shell script
              "exiftool -overwrite_original -Photoshop:CopyrightFlag='True'"
      done
    end repeat
    As I say this works within an Automator app, what changes do I need to make it work in AppleScript?
    Thanks!

    Camelot wrote:
    repeat with i from 1 to count of items in exportFolder
    What is 'exportFolder'? Where is it defined?
    Thanks, 'exportFolder' is defined earlier in the script. The purpose of the script - which is run from within Aperture - is to rename the selected images, export them (to the 'exportFolder'), reset the version name and, using ExifTool, add metadata which Aperture does not write to exported JPEGs.
    I have a version of this which works in Automator but I couldn't see any clues there on setting the path to ExifTool.
    Here's the full (modified) script. Currently it returns an error
    Result:
    error "No file specified" number 1
    so I now need to understand if I can use 'exportFolder' (defined at the start) to tell Finder which folder to use.
    -- Creating filenames by making Version Name  from the IPTC Headline and Filename (with hypens where spaces exist). The Aperture Version Name is used to create the file's name on export. Once exported the Aperture Version Name is reset to its original.
    tell application "System Events"
              set exportFolder to (choose folder with prompt "Choose an export folder")
    end tell
    tell application "Aperture"
              set theSel to (get selection)
              if theSel is {} then
                        error "Please select an image or two!."
              else
                        repeat with theImg in theSel
      -- Creating a new Aperture Version Name which will become the exported file's filename.
                                  tell theImg
                                            set headline to (get value of IPTC tag "Headline" of theImg)
                                            set AppleScript's text item delimiters to " "
                                            set theTextItems to text items of headline
                                            set AppleScript's text item delimiters to "-"
                                            set headline to theTextItems as string
                                            set AppleScript's text item delimiters to {""}
                                            set objectName to (get value of IPTC tag "ObjectName" of theImg)
                                            set newVersion to (headline & "-" & objectName) as string
                                            set name of theImg to newVersion
                                  end tell
                        end repeat
      -- Exporting the files as JPEGs to chosen folder/Project Name using the Version Name as a filename
                        export theSel using export setting "JPEG - Original Size" to exportFolder
      -- Resetting the Aperture Version Name back to filename using IPTC Title (which should be the file's filename without suffex).
                        repeat with theImg in theSel
                                  tell theImg
                                            set title to (get value of IPTC tag "ObjectName" of theImg)
                                            set name of theImg to title
                                  end tell
                        end repeat
              end if
    end tell
    --Using ExifTool to set Photoshop Copyright Status etc
    tell application "Finder" to set theFiles to files of exportFolder as alias list
    repeat with eachFile in theFiles
              do shell script "/usr/bin/exiftool -overwrite_original -Photoshop:CopyrightFlag='True' -Photoshop:URL='http://davidgordon.co.uk/'" & quoted form of POSIX path of eachFile
    end repeat
    display dialog "Done that!" with icon note buttons "OK" default button 1 giving up after 10

  • How do I run a simple script that loads an image into photoshop CS - CS4?

    Hello,
    I am at a loss on how to get my simple application to work. I have a small desktop air application that simply opens Photoshop and runs an action. I used switchboard and the application ran great on PC and MAC. However it only worked for CS3, and CS4 not CS or CS2?. Plus the size of switchboard was a bit large for my small app. I am willing to live with that though . I am using Air with Flex and wanted to know if perhaps there is a beter approach? All the application does is open photoshop, loads an image, and runs an action. Can I do this for all versions of Photoshop using switchboard? Can I do this without switchboard and just use javascript. The big issue is the Air app needs to open Photoshop, and most of the examples have me open PS first and then execute a script located in the PS directory. This needs to work outside of the PS directory. Any examples are appreciated.
    I have looked at the following:
    - SwitchBoard : only works for CS3-CS4 (on my tests)
    - PatchPanel: same issue, plus seperate SDKs
    - ExtendScript: requires script to be run from PS not Air

    Hello,
    I am at a loss on how to get my simple application to work. I have a small desktop air application that simply opens Photoshop and runs an action. I used switchboard and the application ran great on PC and MAC. However it only worked for CS3, and CS4 not CS or CS2?. Plus the size of switchboard was a bit large for my small app. I am willing to live with that though . I am using Air with Flex and wanted to know if perhaps there is a beter approach? All the application does is open photoshop, loads an image, and runs an action. Can I do this for all versions of Photoshop using switchboard? Can I do this without switchboard and just use javascript. The big issue is the Air app needs to open Photoshop, and most of the examples have me open PS first and then execute a script located in the PS directory. This needs to work outside of the PS directory. Any examples are appreciated.
    I have looked at the following:
    - SwitchBoard : only works for CS3-CS4 (on my tests)
    - PatchPanel: same issue, plus seperate SDKs
    - ExtendScript: requires script to be run from PS not Air

  • How do I save a bash script?

    Hi everybody!  Happy noob with a question.  I  would like to start up tint2 with openbox, but I have to open up a terminal to do that.  How can I make a script that does it for me upon startup?

    You put it in autostart.sh - it's described in the wiki:
    https://wiki.archlinux.org/index.php/Op … p_programs
    Please make some effort before posting. Openbox is extremely well documented.
    Closing

  • Running an Apple Script Before going to sleep

    How do I set my applescript to run before I put my computer to sleep...
    I have this feeling I need external software but I'm not sure...

    I use http://macchampion.com/scenario_features.shtml
    dual-core G5/2.3   Mac OS X (10.4.6)   dual screens

  • How do I run an Apple Script only when the computer is awake at the specified time and NOT upon waking after the specified time?

    I've been using Steve Lambert's SelfControl to block myself from certain time-sucking internet sites for a certain period of time every day. I've automated the program launch using an AppleScript that runs based on an iCal alarm, but the problem is that if my computer has been asleep or shut off, the script will run as soon as I wake it up or start it up, and that can be very inconvenient if I'm intending to use my computer not during the hours when I intended to restrict access to such websites.
    So, is there any way to schedule an AppleScript to run *only* if the computer is running at the designated time and not upon waking/starting up after the alarm has passed if the computer was asleep/off?
    I started investigating launchd, as I understand this is the successor to cron/crontab in OS X Lion, but it appears that launchd has the same behavior I dislike in the iCal alarm approach--the script will run upon waking even if the time when it was supposed to run has already passed...unless there is a way to change this behavior?

    The obvious/easy solution would be to add some logic to the script to see what the time is.
    If you expect the script to run at, say, 1pm, but the script checks the time and sees that it's 5pm then you can assume the machine was asleep at the time and thefore you can bail out gracefully.
    if (hours of (get current date)) = 13 then
      -- it's sometime in the 1pm hour...
    end if
    You can fine-tune the check as much as you like

  • How can I run a Unix script from a desktop icon?

    I have a Unix script I've created in vi and would like to run it by double clicking on an icon on my desktop. I would like to do this without the additional application layer of Applescript, Automator or Terminal. Is this possible?
    Thanks in advance.
    Howard

    Sounds like a job for platypus.

  • How do I run a shell script as a different user

    I'm setting up a daily.local file to put in the /etc directory. This file will then be run as root but the file contains a script that must be run as a different user.
    Here's what I've tried.
    su - differentuser path/to/script/script.sh parameter1 parameter2
    I'm getting an error with the script because the parameters are not being passed. The script worked fine in 10.4.11 Server but 10.5.8 Server doesn't like it.
    Any ideas?
    Thanks
    Bart

    I'm setting up a daily.local file to put in the /etc directory. This file will then be run as root but the file contains a script that must be run as a different user.
    Here's what I've tried.
    su - differentuser path/to/script/script.sh parameter1 parameter2
    I'm getting an error with the script because the parameters are not being passed. The script worked fine in 10.4.11 Server but 10.5.8 Server doesn't like it.
    Any ideas?
    Thanks
    Bart

  • How do i run  a shell script?

    Hi,
    i am attempting to update some source packages to the latest up-stream version to eliminate a compile time error described at  http://permalink.gmane.org/gmane.os.apple.fink.devel/21842
    but i am having trouble applying the solution. regretably i have little expierience with this sort of scripting dispite allot of expierience in coding C/C++.
    How do i apply this solution please?
    Thank you,

    Hi,
    i am attempting to update some source packages to the latest up-stream version to eliminate a compile time error described at  http://permalink.gmane.org/gmane.os.apple.fink.devel/21842
    but i am having trouble applying the solution. regretably i have little expierience with this sort of scripting dispite allot of expierience in coding C/C++.
    How do i apply this solution please?
    Thank you,

  • How does one run a shell script at system startup?

    Hi,
    I am trying to unmount my Boot Camp hard drive on my MacBook Pro. Now what I could do is create an automator action, save it as an application and then put it into my user´s login items. I am wondering though - shouldnt it be possible to run a simple shell script command like +diskutil unmount /Volumes/"Boot Camp"+ sometime during the startup process?
    Or to put it another way - is there an easy way to do this or do i have to create an manage a daemon through launchd ?
    Your help is very much appreciated.

    sorry I forgot to mention that there is a bug in Lingon which creates a plist incorrectly if you enter your script explicitly on line 2. At least I haven't been able to make it work. A workaround I always use it the following.
    Save your script as a *plain text* file from your favorite text editor. change the extension to .sh and make the file unix executable. Now, when you ccreate a launch daemon using Lingon, enter the path to that file instead of the script itself.
    This always works for me.
    Good luck!

Maybe you are looking for