Sponsored Content
Full Discussion: Terminal Command into script
Operating Systems OS X (Apple) Terminal Command into script Post 302547705 by xbin on Tuesday 16th of August 2011 11:31:59 AM
Old 08-16-2011
The ntp daemon is alway running on your machine. Whether the machine uses network time is controlled by System Preferences.
Code:
if /usr/sbin/systemsetup -getusingnetworktime  | /usr/bin/grep -q Off
then
    echo "SYNCING TO NETWORK TIME"
    /usr/sbin/systemsetup -setusingnetworktime on
fi

Code is not thoroughly tested-Use at your own risk. It probably should be run as root.

Last edited by xbin; 08-16-2011 at 12:57 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Plz Help : How to use write command to execute command on some other terminal

Hi Group , I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages. - i m writing >write user-id ! ls o ctrl-d inspite of executing the command ls,other terminal shows ! ls. Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies

2. OS X (Apple)

terminal script stops after script command :(.

Hello, i am trying to write a script for terminal for my mac that i may drag into the terminal and will excute the following command: script -akq Desktop/TerminalLogin/Cisco1Bob.txt telnet x.x.x.x the problem is that when i drag the text file to the terminal window the script stops after... (6 Replies)
Discussion started by: drdread
6 Replies

3. Shell Programming and Scripting

how to start SCRIPT command at begin of TERMINAL?

Hello sir, I want to monitor my work on the terminal.I know we can use script command.But every time when I start the terminal, I have to type script to start it.I want to automate it. So where should I include this command so that it will start as soon as I start the terminal ???? (2 Replies)
Discussion started by: nsharath
2 Replies

4. UNIX for Dummies Questions & Answers

what's the terminal command to do this ?

what's the terminal command to do this ? thanks (6 Replies)
Discussion started by: aneuryzma
6 Replies

5. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

6. Shell Programming and Scripting

Is command line invocation of gnome-terminal to run more than one command possible?

Hello, I am trying to learn how to pass something more than a one-command startup for gnome-terminal. I will give an example of what I'm trying to do here: #! /bin/bash # #TODO write this for gnome and xterm USAGE=" ______________________________________________ ${0##*/} run... (0 Replies)
Discussion started by: Narnie
0 Replies

7. UNIX for Dummies Questions & Answers

Script to run a command in a new terminal

Hey, I am trying to write a script that will open all of my session windows, and then secure shell into the appropriate server in the new windows. Seems simple, but I cant get it to work! Please help! :confused: (1 Reply)
Discussion started by: sojo1024
1 Replies

8. Shell Programming and Scripting

perl: Command works in terminal, but not in shell script

Hi, the following command works in the terminal no problem. samtools view -h rawlib.bam | perl -ne '{ @line = split( /\s+/ ); $match = 0; while( $line =~ /(\d+)M/g ) { $match = $match + $1 } if( $match >= 80 || $_ =~ /^\@/ ) { print $_ } }' | java -Xmx12G -jar... (8 Replies)
Discussion started by: jdilts
8 Replies

9. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

10. Linux

Terminal command

I need to execute apt-cdrom to designate the pendrive using LM 18.3x 'live". (instead of CD-Rom) Rick (7 Replies)
Discussion started by: 69Rixter
7 Replies
SYSTEMSETUP(8)						    BSD System Manager's Manual 					    SYSTEMSETUP(8)

NAME
systemsetup -- configuration tool for certain machine settings in System Preferences. SYNOPSIS
systemsetup [-getdate] [-setdate mm:dd:yy] [-gettime] [-settime hh:mm:ss] [-gettimezone] [-listtimezones] [-settimezone timezone] [-getusingnetworktime] [-setusingnetworktime on | off] [-getnetworktimeserver] [-setnetworktimeserver timeserver] [-getsleep] [-setsleep minutes] [-getcomputersleep] [-setcomputersleep minutes] [-getdisplaysleep] [-setdisplaysleep minutes] [-getharddisksleep] [-setharddisksleep minutes] [-getwakeonmodem] [-setwakeonmodem on | off] [-getwakeonnetworkaccess] [-setwakeonnetworkaccess on | off] [-getrestartpowerfailure] [-setrestartpowerfailure on | off] [-getrestartfreeze] [-setrestartfreeze on | off] [-getallowpowerbuttontosleepcomputer] [-setallowpowerbuttontosleepcomputer on | off] [-getremotelogin] [-setremotelogin on | off] [-getremoteappleevents] [-setremoteappleevents on | off] [-getcomputername] [-setcomputername computername] [-getstartupdisk] [-liststartupdisks] [-setstartupdisk path] [-getwaitforstartupafterpowerfailure] [-setwaitforstartupafterpowerfailure value] [-getdisablekeyboardwhenenclosurelockisengaged] [-setdisablekeyboardwhenenclosurelockisengaged yes | no] [-getkernelbootarchitecturesetting] [-setkernelbootarchitecture i386 | x86_64 | default] [-version] [-help] [-printCommands] DESCRIPTION
The systemsetup command is used to configure certain per-machine settings typically configured in the System Preferences application. The systemsetup command requires at least "admin" privileges to run. A list of flags and their descriptions: -getdate Displays the current date. -setdate mm:dd:yy Use this command to set the current month, day, and year. -gettime Displays the current time in 24-hour format. -settime hh:mm:ss Sets the current time. The provided time argument should be in 24-hour format. -gettimezone Displays current time zone. -listtimezones Lists all time zones supported by this machine. -settimezone timezone Use this command to set the local time zone. Use "-listtimezones" to list valid timezone arguments. -getusingnetworktime Displays whether network time is on or off. -setusingnetworktime on | off Sets whether using network time is on or off. -getnetworktimeserver Displays the currently set network time server. -setnetworktimeserver timeserver Use this command to designate a network time server. Enter the IP address or DNS name for the network time server. -getsleep Displays amount of idle time until machine sleeps. -setsleep minutes Sets amount of idle time until computer sleeps. Specify "Never" or "Off" for computers that should never sleep. Important: if you set the system to sleep, you will not be able to administer the server remotely while it is sleeping. -getcomputersleep Display amount of idle time until computer sleeps. -setcomputersleep minutes Set amount of idle time until computer sleeps. Specify "Never" or "Off" for never. -getdisplaysleep Display amount of idle time until display sleeps. -setdisplaysleep minutes Set amount of idle time until display sleeps. Specify "Never" or "Off" for never. -getharddisksleep Display amount of idle time until hard disk sleeps. Specify "Never" or "Off" for never. -setharddisksleep minutes Set amount of idle time until hard disk sleeps. Specify "Never" or "Off" for never. -getwakeonmodem Displays whether wake on modem is on or off. -setwakeonmodem on | off Use this command to specify whether or not the server will wake from sleep when modem activity is detected. -getwakeonnetworkaccess Displays whether wake on network access is on or off. -setwakeonnetworkaccess on | off Use this command to specify whether the server wakes from sleep when a network admin packet is sent to it. -getrestartpowerfailure Displays whether restart on power failure is on or off. -setrestartpowerfailure on | off Use this command to specify whether the server automatically restarts after a power failure. -getrestartfreeze Displays whether restart on freeze is on or off. -setrestartfreeze on | off Use this command to specify whether the server restarts automatically after the system freezes. -getallowpowerbuttontosleepcomputer Enable or disable whether the power button can sleep the computer. -setallowpowerbuttontosleepcomputer on | off Enable or disable whether the power button can sleep the computer. -getremotelogin Displays whether remote login (SSH) is on or off. -setremotelogin [-f] on | off Sets remote login (SSH) to either on or off. Important If you turn off remote login, you won't be able to administer the server using remote command line tools and SSH. To turn remote login back on, you'll need to connect a monitor and keyboard to the server to administer it locally. Use "setremotelogin -f off" to suppress prompting when turning remote login off. -getremoteappleevents Displays whether remote apple events are on or off. -setremoteappleevents on | off Use this command to set whether the server responds to events sent by other computers (such as AppleScripts). -getcomputername Displays computer name. -setcomputername computername Sets computer name to <computername>. This name is used by AFP. -getlocalsubnetname Display local subnet name. -setlocalsubnetname name Set local subnet name to <name>. -getstartupdisk Displays current startup disk. -liststartupdisks Lists all valid startup disks on this computer. -setstartupdisk path Sets current startup disk to the indicated path. Valid arguments can be listed using "-liststartupdisks." -getwaitforstartupafterpowerfailure Get the number of seconds after which the computer will start up after a power failure. -setwaitforstartupafterpowerfailure seconds Set the number of seconds after which the computer will start up after a power failure. The <seconds> value must be a multiple of 30 seconds. -getdisablekeyboardwhenenclosurelockisengaged Get whether or not the keyboard should be disabled when the X Serve enclosure lock is engaged. -setdisablekeyboardwhenenclosurelockisengaged yes | no Set whether or not the keyboard should be disabled when the X Serve enclosure lock is engaged. -getkernelbootarchitecturesetting Gets the Kernel Architecture setting from the com.apple.Boot.plist. -setkernelbootarchitecture i386 | x86_64 | default Set the kernel to boot in 32 or 64 bit mode on next boot. default removes the setting. -version Displays version of systemsetup tool. -help Displays a list of all the commands available in the System Setup Tool, with explanatory information. -printCommands Displays a list of commands with no detail. EXAMPLES
systemsetup -setdate 04:15:02 systemsetup -settime 16:20:00 systemsetup -settimezone US/Pacific systemsetup -setnetworktimeserver time.apple.com FILES
/usr/sbin/systemsetup SEE ALSO
networksetup(8) Mac OS X April 15, 2002 Mac OS X
All times are GMT -4. The time now is 04:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy