Sponsored Content
Top Forums Shell Programming and Scripting Expect command when triggered by launchd Post 302732615 by rowie718 on Sunday 18th of November 2012 05:45:53 PM
Old 11-18-2012
Expect command when triggered by launchd

Hi folks,

Im having trouble with an expect command in a shell script I use to back up mac os x servers. This one is being run on a 10.8.2 Server as part of a larger bash script. The script executes perfectly all the way through when triggered on the command line, but when launchd triggers it at the scheduled time, the rest of the script executes fine, but the expect command doesnt send the password and so the slapconfig command doesn't complete, it just hangs there waiting.

Here is the relevant portion of my script:

Code:
/usr/bin/expect -c '
spawn /usr/sbin/slapconfig -backupdb "'"${recover}/_OD_Backup_${date}"'"
sleep 10
expect "'"Enter archive password:"'"
send "'"${passwd}\\r"'"
interact
' >/Users/admin/Desktop/slapconfig.log

Ive redirected stdout to a text file to see where it stops and this is what it outputs:

"spawn /usr/sbin/slapconfig -backupdb /Volumes/RAID/Administration/Backups/server.domain.com/20121116/_OD_Backup_20121116
2012-11-17 00:06:42 +0000 slapconfig -backupdb
Enter archive password:
"

Perhaps this is a problem with launchd running the script commands in a subshell or something along those line? I'm a bit stumped why the expect command completes when the script is triggered on the command line but not when scheduled with launchd.

Any help would be greatly appreciated!

Last edited by rowie718; 11-18-2012 at 06:53 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expect and auto expect command

I need to run a remote application(GUI) in a client.i.e on running a script in the client machine i should get the GUI application which is running in the server by providing password through the script.Will expect or autoexpect command suit for this scenario? could anyone help me by posting some... (0 Replies)
Discussion started by: arun_v
0 Replies

2. OS X (Apple)

interval in a launchd script

Hi, i'm planning a to automate my backup with a rsync user deamon in my launchd and let that run every 2 hours. my server contains a lot of video data which can expand rapidly , up to 1TB, in an interval of 2 hours. now i'm wondering what will happen when a rsync is running longer then the... (1 Reply)
Discussion started by: wessel
1 Replies

3. OS X (Apple)

[launchd] Creating a basic firewall

Hi, I'm trying to use launchd to detect whether certain ports are opened and if they are then to take some appropriate action, e.g. close the port or, worst case scenario, down the whole net connection. Apparently, force closing a port is not possible without killing the offending binary so... (3 Replies)
Discussion started by: ASGR
3 Replies

4. UNIX for Dummies Questions & Answers

Alert to be triggered

Hi, I need an alert to be triggered if any filesystem(imagine there are n no of filesystems) reaches more than 90%, it should send an alert to the mailbox stating which filesystem is at what percentage. How can I achieve this in unix? Many thanks. (8 Replies)
Discussion started by: venkatesht
8 Replies

5. Shell Programming and Scripting

Help with expect command

Hi, I am using following commands in my script to send a password to scp command. Everything is working fine except that I need a return code from the scp command. Do any one have an idea how to receive the exit code of scp command from expect. /usr/bin/expect << EOF spawn -noecho scp -pq... (0 Replies)
Discussion started by: pvamsikr
0 Replies

6. Shell Programming and Scripting

Expect command- need help

Hi All, I need help in making my script run perfectly as expected. This is a snippet from my script. I am trying to read the ";" from the below output using the expect command, but the command is not detecting it. Could you please help me correct the expect string? Snippet: ---- ---... (2 Replies)
Discussion started by: sonicj
2 Replies

7. UNIX for Dummies Questions & Answers

Launchd-owned processes unexpected behavior

Ok, so I have been struggling with this for a few days and I think I need an explanation of a few things before I go any further. I'm not sure it's possible to do what I'm trying, so before I pull my hair out, here is what I'm doing: I have written a program in LiveCode that sits on our... (2 Replies)
Discussion started by: nextyoyoma
2 Replies

8. Shell Programming and Scripting

Capture output of command triggered in background

Is there any way to trigger a sequence of commands in parallel and capture their output in variables? e.g. something on the following lines x=`echo "X" &` y=`echo "Y" &` z=`echo "Z" &` so that $x, $y, and $z evaluate to X, Y and Z res. (7 Replies)
Discussion started by: jawsnnn
7 Replies

9. Shell Programming and Scripting

Scripts triggered via 'expect' - stderr lost

I have a bash script on server that runs fine when run interactively and writes stderr output to a file. However, when invoked through a 'expect' script run on Mac OS my laptop which does ssh to the server : generates the expected file, but file has no content. I suspect the stderr is getting... (1 Reply)
Discussion started by: sdudc
1 Replies

10. Shell Programming and Scripting

Email need to be triggered

hi, Currently, in my code, the errors are written in log file. Additionally, i need to trigger the email of error captured. can we modify this script with email triggered along with existing command. echo "ERROR: $SCRIPT: $*" >>$LOGFILE (1 Reply)
Discussion started by: gowthamsoft
1 Replies
mkpassdb(8)						    BSD System Manager's Manual 					       mkpassdb(8)

NAME
mkpassdb -- Mac OS X Server Password Server database creation tool SYNOPSIS
mkpassdb -deleteslot slot-ID mkpassdb -dump [-v] mkpassdb -dump [slot-ID] mkpassdb -header mkpassdb -kerberize mkpassdb -key mkpassdb -list mkpassdb -mergedb path mkpassdb -mergeparent path mkpassdb -setadmin slot-ID [admin-class (0-7)] mkpassdb -setglobalpolicy "policy1=value1 policy2=value2 etc." mkpassdb -setkerberos slot-ID KerberosRealm mkpassdb -setkeyagent slot-ID mkpassdb -setcomputeraccount [off] mkpassdb -setrealm realm mkpassdb -getreplicationinterval mkpassdb -setreplicationinterval seconds [policy] mkpassdb -rekeydb [key-size-in-bits] mkpassdb [-u user] [-m mech] [-a] [-b] [-e count] [-n replica-name] [-o] [-p] [-q] DESCRIPTION
mkpassdb creates or modifies the password server database directly. mkpassdb must be run as root; it will exit otherwise. The -list command is the only exception. This tool's purpose is to create and manage the password server database. It performs operations that are not supported by the password server protocol because of security concerns. These operations include the creation and destruction of the database itself, the creation of the RSA security keys that establish the identity of the password server, the trusted mechanism list, and the genesis of administrator accounts. It also allows the root account to make some password server changes on the local system. -deleteslot Invalidates a slot ID in the database. -dump Outputs all of the User IDs and their corresponding user names. If a slot-ID is specified, it prints out more detailed information for a single slot. If the [-v] option is used, additional columns are included. -header Outputs the database header information. -kerberize Attempts to add kerberos principals for all non-kerberos accounts in password server. -key Outputs the RSA public key stored in the database. -list Outputs all of the SASL mechanisms available to the password server. -mergedb This command is a low-level command that is invoked by a higher-level tool in normal usage. Refer to the restoredb command in the slapconfig man page. This command merges a snapshot of the password server database into the cur- rent database whether or not the daemon is running. This command takes existing LDAP users, looks for their data in the specified db file, and merges their db information. If there is data in the db without a corresponding LDAP user or computer, it is not merged. The identity elements of the password server, including RSA keys and replica name, are changed to the snapshot's contents. -mergeparent This command is a low-level command that is invoked by a higher-level tool in normal usage. Refer to the mergedb command in the slapconfig man page. This command merges a snapshot of the password server database into the cur- rent database whether or not the daemon is running. This command takes existing LDAP users, looks for their data in the specified db file, and merges their db information. If there is data in the db without a corresponding LDAP user or compute r, it is not merged. The current identity of the password server is preserved. -setadmin Promotes a slot-ID to have administrator privileges for the password server. By default, administrators set with mkpassdb receive the most priveleged rank (0). -setglobalpolicy Sets the default policies for all users. -setkerberos Assigns a Kerberos realm to a password server account. -setkeyagent Promotes a slot-ID to have enough administrator privileges to retrieve session keys on behalf of other accounts. -setcomputeraccount Informs the password server that the account belongs to a computer rather than a user. Computer accounts are not subject to policies and do not expire. Using the optional "off" argument changes the state back to a user account. -setrealm Sets the password server's SASL realm. -getreplicationinterval Gets the number of seconds between replication attempts. -setreplicationinterval Sets the number of seconds between replication attempts. -rekeydb Generates a new RSA public/private key pair for the database. Valid sizes are 1024, 2048, or 3072. This command should be invoked by a higher-level tool. If run from the command line, existing users will not be able to authen- ticate. The PasswordService daemon must be turned off with, "NeST -stoppasswordserver" before this command can be used. OPTIONS
The following options are available: -a add a new administrator to an existing database. -b add a new non-administrative user to an existing database. -e expand the database to a fixed number of records. If the number is greater than the current size of the database, then the database is expanded; otherwise, no action is performed. This option is used by other setup tools when establishing a replica database. There is no reason to use it from the command line. -m mech establishes a mechanism as weak. If a mechanism is considered weak, then it can be used to verify passwords but the password server will not allow write operations to its database. The mechanisms SMB-NT, SMB-LAN-MANAGER, CRYPT, and APOP are always in the weak list. Directory Services uses DHX to perform write operations to the password server. -n name Assign a name to a replica -o overwrite an existing database. Replacing an existing database is extremely destructive and should not be done unless all password server users have been removed from the directory system. -p prompt for a password -q quiet -u user Add this user name to the database. USAGE
In typical usage, mkpassdb is invoked by another tool. It is used directly on rare occasion. FILES &; FOLDERS /Library/Preferences/com.apple.passwordserver.plist - the PasswordService preferences file /usr/sbin/PasswordService - the password service daemon /var/db/authserver/authservermain - password database (guard this) /var/db/authserver/authserverfree - list of free (reusable) slots in the database /var/db/authserver/authserverreplicas - table of password server replicas SEE ALSO
NeST(8) PasswordService(8) slapconfig(8) Mac OS X Server 21 February 2002 Mac OS X Server
All times are GMT -4. The time now is 03:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy