Scripts run via Automator use the default search path which usually does not include /usr/local/bin. In your case an easy fix would be to put
somewhere at the beginning of the script.
You need to set 'execute' on the file for it to allow you to run it:
chmod u+x /path/to/file.command
u is the owner of the file, +x adds 'execute', so u+x gives the owner of the file the ability to execute it
…then you can run it in the future by double-clicking it.
sudo launchctl bootout gui/$(id -u <username>)
sudo launchctl bootout user/$(id -u <username>)
Replace username with the target user's user name or replace the whole subshell with the user's uid. This tells launchctl to teardown the users login session (gui specifically refers to the user's temporary login session, user specifies the users ...
A .command script should do the trick
Open TextEdit and create a new file
Convert it to plain text by clicking Format > Make Plain Text
Add your commands, one per line.
For example, you could do:
Run chmod u+x ~/Desktop/myCommandScript.command in your terminal, where ~/...
To log out purely from terminal (or a remote ssh session), just kill the loginwindow process:
sudo pkill loginwindow
You could get fancy and specify the user if multiple users have a loginwindow process, but this is an easy one shot, no prompt way to end a user's graphical session.
There are two programs that I am aware of which will easily allow you to configure your Mac to send email from the command line.
I have written up HOWTOs for both of them:
Of the two, I suggest msmtp.
Configuration is complicated enough that I'm not sure if I should replicate all of the steps here, but I will mention that if you use
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
tell application "System Events" to tell process "System Preferences"
click checkbox 1 of tab group 1 of window 1
quit application "System Preferences"
You could also use defaults write -g com.apple.keyboard.fnState -bool true, ...
Terminal runs the Unix shell, (bash, zsh, and others) which is obviously a command line scripting environment, which can execute complex scripts, particularly file processing.
Python 2.7 comes bundled with MacOS, and always has done. Future?.
Ruby, Perl are also included.
In Mac OS X Lion the user crontabs are stored in /var/at/tabs. In the past they were located in /var/cron/tabs.
You should use crontab -e to interact with these in general, but knowing the location is useful for when you want to restore them from a backup of your disk, or something similar.
If you use bash, add the alias commands to ~/.bashrc and save a file like this as ~/.bash_profile:
When bash is invoked as an interactive non-login shell, it reads .bashrc but not .bash_profile. When bash is it is invoked as an interactive login shell, it reads .bash_profile but not .bashrc.
Terminal and iTerm open new shells as login shells ...
Well, here you go with an AppleScript for that.
First, create the AppleScript:
Create a Quick Action
Set the input to no input
Drag and Drop the Run AppleScript workflow element onto the grey space.
Paste the code from below into the AppleScript
Save the workflow as Create new file
If you have iCloud Drive activated, make sure you are saving ...
All processes get paused when the system goes to sleep, independent of whether the process is part of macOS, an application or some code you wrote on your own. After the system wakes up again, all processes will continue to run.
With the benefit of several years of hindsight:
user588's answer and koiyu's answer work well, but they rely on utilities (Rez, DeRez, and SetFile) that:
aren't installed by default (they come with either Xcode or the developer command-line utilities)
are now deprecated (Rez and DeRez, because they relate to Carbon)
osxiconutils look interesting, but won'...
This is very easy to do.
For efficiency (and cool factor), I would use a tool like Lingon to launch this script periodically using launchctl/launchd instead of each time you start a shell. On my MacBook, it takes 3 seconds to update the second time (no work done, DNS cache set, etc...) and it take 10 second to run the first time (no work done) or 15+ ...
There is a very well documented open source script that reads the software update catalogs and parses them for the major macOS installer components, prompts you which build and version to download and will then commence to download each portion to your filesystem and then build an installer application or image based on the options you choose.
As patrix has pointed out in a comment, you can set up any Mac to start up or wake up, and sleep or shut down at specific times, via the System Preferences -> Energy Saver -> Schedule... settings.
You could also try using AppleScript, e.g. this code (edit it with Script Editor, then save as an Application):
tell application id "com.apple.systemevents" -- ...
Take the script that you created:
echo "plugin L2TP.ppp">>/etc/ppp/options
Save it in your home directory, or a 'scripts' directory inside your home directory, as l2tp.sh. Allow it to be executed(write this command in Terminal):
chmod 700 ~/path/to/l2tp.sh
To execute the file using sudo (root ...
This has worked for me in the past:
Log out (with confirmation)
osascript -e 'tell app "System Events" to log out'
Log out directly (no confirmation)
osascript -e 'tell app "System Events" to «event aevtrlgo»'
osascript -e 'tell application "loginwindow" to «event aevtrlgo»'
This way any running application will get noticed and can terminate in a ...
There is no native alternative. You must acquire watch from using Homebrew (brew install watch) or MacPorts (port install watch) if you require an actual executable.
You can however, emulate the function of watch. That can be accomplished in a standard bash while loop (from Stack Overflow by Daniel Pittman):
You can emulate the basic functionality with ...
The most basic way to send mail is trough a telnet session with the smtp server of your provider/network. After you contacted the server and after every command the server will answer if it accepts the command with something like "250 OK", or if not with an error message.
All details can be found in RFC2821 - Simple Mail Transfer Protocol, Google for it.
I'm assuming that you'd like to initiate this procedure as opposed to having it run at a regularly scheduled time.
My approach would be to initiate this from the command line, but any commands can be run in a shell script component of an Automator script with some modification. The following approach combines a few components to get the job done:
A tell ...
I'm stumped as to why cp is behaving this way if there's no alias involved. However, there is a quick-dirty-and-dangerous utility provided for this exact situation: yes. You can use it to pipe a continuous stream of affirmatives into any command that gives you confirmation prompts (you can use it to send any text, but the default is "y").
yes | cp foo bar ...
This worked for me, it was written with Lion in mind but works for Mountain Lion. Btw this is using Gmail so if you're not...
You don't need to download anything! (just setup a gmail account)
Configure Postfix for Gmail SMTP Edit file /etc/postfix/main.cf
You can use pmset to do this and it will be a "once and done" solution.
Once you issue the pmset command, it will shutdown/startup/wake on the schedule you set; you won't have to create a script that runs at a predetermined time each time.
pmset uses this format:
pmset schedule day/date time
Here are a few examples:
pmset repeat sleep MTWRF 23:30:00 puts ...
Check out cocoaDialog:
cocoaDialog is an OS X application that allows the use of common GUI controls such as file selectors, text input, progress bars, yes/no confirmations and more with a command-line application. It requires no knowledge of Cocoa, and is ideal for use in shell and Perl scripts (or Ruby, or Python, or... etc).
It's a pretty simple ...
For a more general solution to the bash environment in automator differing from your own you could simply load your personal bash profile at the first line of the automator bash script:
This will make the path and any other environment variables you're used to using available from your automator script.