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
slapconfig(8)						    BSD System Manager's Manual 					     slapconfig(8)

NAME
slapconfig -- tool to configure slapd and related daemons SYNOPSIS
slapconfig command [command-options] [-q] DESCRIPTION
slapconfig is a utility for configuring slapd. It must be run by root. USAGE
-q suppress prompts. Queries -defaultsuffix Returns the default suffix which is based on the machine's DNS name, or hostname if DNS is not available. -getclientconfig Returns whether this machine is an LDAP client, not a client, or advanced. -getldapconfig Returns the LDAP server settings. -getmacosxodpolicy Returns a property list containing the directory binding settings. -getmasterconfig Returns the list of replicas and replication interval. -getpasswordserveraddress Returns the IP address of the default password server. -getreplicaconfig Returns the master address and last update date. -getstyle Returns whether configuration is master, replica, client, or standalone. -help Print usage information. -ver Displays version information. Setup -addreplica [--serverID num] [--guid D1C9C376-D940-404D-9941-7AD24E6A37DA] <replica-address> Adds a replication link with the specified server. The serverID and GUID of the remote machine you'd like to replicate with. The serverID and GUID can be viewed in the target machine's computer record. Replication links are unidirectional, the corresponding command should be run on the target server as well to get full replication working. Caution should be exercised with this command, it is best to avoid repli- cation loops. -changeip <old-ip> <new-ip> [<old-host> <new-host>] Updates configuration records and files to contain the new host information. It does not change the IP address in Network preferences. -createldapmasterandadmin [--allow_local_realm] [--certAuthName <Cert Auth Name>] [--certAdminEmail <Cert Admin Email>] [--certOrgName <Cert Org Name>] <new-admin> <new-fullname> <new-uid> [<search base suffix> [<realm>]] Creates a new master LDAP server. Copies the root account to the new master domain. Creates a new directory node administrator. -createreplica [--certAdminEmail <Cert Admin Email>] <master IP or name> <admin user> Create a new replica from an existing LDAP master. -createrootcertauthority <Certificate Authority Name> <Certificate Authority Admin Email> <Certificate Authority Organization Name> Create a CA on the OD master. -destroyldapserver [diradmin] Turns off the LDAP server and deletes its database. The optional argument of the diradmin account name will then prompt for the diradmin password and will inform all replication peers of the server's destruction. -promotereplica <admin-user> <archive-path> Converts an existing replica into a master using the current database. Path to an archive from the master can given in order to add the root CA's keys to the promoted master. -removereplica [--guid D1C9C376-D940-404D-9941-7AD24E6A37DA] -<replica-address> Removes a replication link with the specified server. The GUID of the remote server being removed should be passed in with the --guid option. Replication links are unidirectional, so the corresponding command should be run on the target server to remove the other half of an existing replication link. -setclient Configures the machine to bind using DHCP if it is not already a client. -setldapconfig [-maxresults <maximum search results>] [-searchtimeout timeout] [-ssl on|off] [-sslidentity <identity name>] [-sslserialnumber <certificate serial number>] Applies the specified settings and restarts slapd. Settings not specified are unchanged. -setstandalone Configures the machine to only use the local directory. -setmacosxodpolicy [-binding [disabled|enabled|required]] [-cleartext [blocked|allowed]] [-encrypt [yes|no]] [-sign [yes|no]] [-clientcaching [yes|no]] [-man-in-middle [blocked|allowed]] Sets directory binding options. -startldapserver Configures launchd to run slapd. -stopldapserver Configures launchd not to run slapd. -updateaddresses Merges new interfaces into the list of LDAP replicas. Password Server -startpasswordserver Sets up a launchd plist file and starts the password server. -stoppasswordserver Sets the launchd plist file to be disabled and stops the password server. Runtime -enableslapdlog Turns on the LDAP server logging to /var/log/slapd.log. -setfullsyncmode [yes | no] The LDAP server defaults to running in a "full sync mode" to ensure database transactions are fully flushed to disk. This improves data integrity in the event of a power loss, but can result in slower performance when importing large datasets. Setting this option to no disables this functionality temporarily in order to speed up large imports. After the import has been completed, this option should be set back to yes for normal operation. Backup and Restore -backupdb <archive-path> Creates an archive containing the LDAP, Password Server and Kerberos databases. It also contains Certificate Authority related data. -restoredb <archive-path> Restores a directory to the backed-up state. ENVIRONMENT
The environment variable SSOUtilDebugLevel can be set to change the verbosity of the log. Valid values are [0-9]. The default value is 1. FILES
/usr/sbin/slapconfig SEE ALSO
DirectoryService(1), slapd(8) MacOSX June 2, 2019 MacOSX
All times are GMT -4. The time now is 08:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy