[NewB] calling shell from ObjC within a PreferencesPane

  • Hey all,

    i'm writing a preferences pane for a light nntp server "LeafNode"
    <http://leafnode.sourceforge.net/>.

    in order to start this server i'm using a launchd "LaunchDaemons" .

    the plist being "/Library/LaunchDaemons/net.sourceforge.leafnode.plist"

    the the agent label "net.sourceforge.leafnode".

    i know the wat to start/stop yjis server from command line.

    however i'd designing a preference pane able to start/stop this
    server provided the user authentificate as admin.

    the basic way to start the server using the terminal being :

    > sudo launchctl start net.sourceforge.leafnode

    then my question is how could i call launchdctl from ObjC ?

    i know how to call shell script from AppleScript and Ruby but not *
    at all * from ObjC.

    also i will have to open a window for the user to authentificate, are
    they special window/panel for that ?

    i said one question , i do have other.

    this server as process to be put in daily crontab, i know how to use
    the crontab under shell but how from ObjC.

    best,

    Yvon
  • Hi Yvon,

    There are two ways:

    NSTask (Check Apples docs for info on this class)
    system(You provide a string (eg. "ls -alh /"))

    Good luck, Alan

    PS. Questions such as this one have been asked *very* many times.
    Always search this lists archive at cocoabuilder.com before posting,
    saves you/us time and some of us get *really* annoyed when people ask
    a common question.

    On 10/31/06, Yvon Thoraval <yvon_thoraval...> wrote:
    > Hey all,
    >
    > i'm writing a preferences pane for a light nntp server "LeafNode"
    > <http://leafnode.sourceforge.net/>.
    >
    > in order to start this server i'm using a launchd "LaunchDaemons" .
    >
    > the plist being "/Library/LaunchDaemons/net.sourceforge.leafnode.plist"
    >
    > the the agent label "net.sourceforge.leafnode".
    >
    > i know the wat to start/stop yjis server from command line.
    >
    > however i'd designing a preference pane able to start/stop this
    > server provided the user authentificate as admin.
    >
    > the basic way to start the server using the terminal being :
    >
    >> sudo launchctl start net.sourceforge.leafnode
    >
    > then my question is how could i call launchdctl from ObjC ?
    >
    > i know how to call shell script from AppleScript and Ruby but not *
    > at all * from ObjC.
    >
    > also i will have to open a window for the user to authentificate, are
    > they special window/panel for that ?
    >
    > i said one question , i do have other.
    >
    > this server as process to be put in daily crontab, i know how to use
    > the crontab under shell but how from ObjC.
    >
    > best,
    >
    > Yvon
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<alanrogersmith...>
    >
    > This email sent to <alanrogersmith...>
    >

    --
    // Quotes from yours truly -------------------------
    "You don't forget, you just don't remember."
    "Maturity resides in the mind."
    "Silence is the Universe's greatest gift."
    "When the World realizes that religion really is unimportant, then it
    shall evolve."
  • On Oct 31, 2006, at 8:24 AM, Yvon Thoraval wrote:

    > the basic way to start the server using the terminal being :
    >
    >> sudo launchctl start net.sourceforge.leafnode
    >
    > then my question is how could i call launchdctl from ObjC ?

    NSTask

    > also i will have to open a window for the user to authentificate

    No you won't - the authentication framework will pop up a window
    automatically if needed. See:

    <http://developer.apple.com/documentation/Security/Conceptual/
    authorization_concepts/index.html
    >
    <http://developer.apple.com/documentation/Security/Reference/
    authorization_ref/index.html
    >

    > this server as process to be put in daily crontab

    I thought you said it was a daemon? Make up your mind.

    > , i know how to use the crontab under shell but how from ObjC.

    There's no programmatic API that I know of. Just use NSTask to run
    the shell command.

    sherm--

    Web Hosting by West Virginians, for West Virginians: http://wv-www.net
    Cocoa programming in Perl: http://camelbones.sourceforge.net
  • Le 31 oct. 06 à 14:59, Sherm Pendley a écrit :

    > NSTask
    >
    >> also i will have to open a window for the user to authentificate
    >
    > No you won't - the authentication framework will pop up a window
    > automatically if needed. See:
    >
    > <http://developer.apple.com/documentation/Security/Conceptual/
    > authorization_concepts/index.html>
    > authorization_ref/index.html>

    fine thanks.
    >

    >> this server as process to be put in daily crontab
    ---------------------^- i do have forgotten an "h" here ...
    > I thought you said it was a daemon? Make up your mind.

    yes their is daemon BUT in order to expire old posts leafnode (the
    daemon) has another bin called "texpire" which as to be run, as
    default value, once a day.

    >
    >> , i know how to use the crontab under shell but how from ObjC.
    >
    > There's no programmatic API that I know of. Just use NSTask to run
    > the shell command.

    ok i'll see with "NSTask"

    thanks again,

    best

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

    This email sent to <cocoa...>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today