Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

2 problems.




I realize this may be newbie type questions or questions from an inexperienced programmer but, all that I ask is that you please stop laughing long enough to provide me with a useable answer that doesn't include RTFM or go search.


problem #1

I have the following shell script, valid values for VALUE are '-YES-' or '-NO-'

#!/bin/sh

NAME="MAILTRANSPORT"
VALUE=$1
PATTERN="^$NAME="
HOSTCONFIG=/etc/hostconfig

if [ -z $(grep "$PATTERN" $HOSTCONFIG) ]; then
    # create initial entry
    echo "$NAME=$VALUE" >> $HOSTCONFIG
else
    # replace entry with new value
    TMP=$(mktemp /tmp/hostconfig.XXXXXX) || exit 1
    grep -v "$PATTERN" $HOSTCONFIG >> $TMP
    echo "$NAME=$VALUE" >> $TMP

    mv $TMP $HOSTCONFIG
    chmod 644 $HOSTCONFIG
    chown root:wheel $HOSTCONFIG
fi


I need to duplicate this process in a binary application (made in XCode) so I'm looking for some source code that does this, do you have something that can help me?


problem #2

How do I determine if an application/daemon is running, the app/daemon has a pid and a socket file, if you have some source code for this I'd appreciate it.

-- Dale

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.