run a shell command with C code in OS X

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sushi boi

    run a shell command with C code in OS X

    hi,
    I'm a first year student at UNSW Sydney, i was wondering if somebody
    could tell me how to run a terminal command from within OS X. A easy
    to understand example of why i would want this is:
    1. Running winRAR or some other compression program to decompress a
    file within the working directory.
    2. Running growlnotify to give user feedback rather then through the
    command line.
    3. running the say command to get the computer to say something
    4. running screencapture

    i would be extremely greatfull if anyone out there can be of some
    assistance.

    thanks in advanced!

  • santosh

    #2
    Re: run a shell command with C code in OS X

    sushi boi wrote:
    hi,
    I'm a first year student at UNSW Sydney, i was wondering if somebody
    could tell me how to run a terminal command from within OS X.
    And why are shell commands in OS X topical in a Standard C group? Post to a
    system specific group like <news:alt.comp. os.macor at least
    <news:comp.prog ramming>

    <snip>

    Comment

    • christian.bau

      #3
      Re: run a shell command with C code in OS X

      On Jul 28, 1:32 pm, sushi boi <sushant...@gma il.comwrote:
      hi,
      I'm a first year student at UNSW Sydney, i was wondering if somebody
      could tell me how to run a terminal command from within OS X. A easy
      to understand example of why i would want this is:
      1. Running winRAR or some other compression program to decompress a
      file within the working directory.
      2. Running growlnotify to give user feedback rather then through the
      command line.
      3. running the say command to get the computer to say something
      4. running screencapture
      >
      i would be extremely greatfull if anyone out there can be of some
      assistance.
      >
      thanks in advanced!
      Very off-topic, but go to developer.apple .com and go from there.

      Comment

      • SM Ryan

        #4
        Re: run a shell command with C code in OS X

        sushi boi <sushant.40@gma il.comwrote:
        # hi,
        # I'm a first year student at UNSW Sydney, i was wondering if somebody
        # could tell me how to run a terminal command from within OS X. A easy
        # to understand example of why i would want this is:

        If your system supports the system() function, just call
        int rc = system("shell command in some string expression");

        It will run the command with a shell (or as if with a shell), but
        the implementation is system specific.

        --
        SM Ryan http://www.rawbw.com/~wyrmwif/
        TEMPORARILY CLOSED
        BE OPENED AFTER FIRST PERIOD

        Comment

        • Keith Thompson

          #5
          Re: run a shell command with C code in OS X

          santosh <santosh.k83@gm ail.comwrites:
          sushi boi wrote:
          >I'm a first year student at UNSW Sydney, i was wondering if somebody
          >could tell me how to run a terminal command from within OS X.
          >
          And why are shell commands in OS X topical in a Standard C group? Post to a
          system specific group like <news:alt.comp. os.macor at least
          <news:comp.prog ramming>
          The question is actually quite topical if you ignore the irrelevant
          OS X aspect of it. The answer is the system() function.

          (There may well be other approaches that are specific to OS X; those
          approaches would be off-topic.)

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
          "We must do something. This is something. Therefore, we must do this."
          -- Antony Jay and Jonathan Lynn, "Yes Minister"

          Comment

          • sushi boi

            #6
            Re: run a shell command with C code in OS X

            sorry for being off topic..i'll go to those other pages next time..
            i came here because its the C programming forum... and i thaught i
            needed a C fn to do what i needed it to do.. not a OS-X specific Fn

            Comment

            • SM Ryan

              #7
              Re: run a shell command with C code in OS X

              sushi boi <sushant.40@gma il.comwrote:
              # sorry for being off topic..i'll go to those other pages next time..
              # i came here because its the C programming forum... and i thaught i
              # needed a C fn to do what i needed it to do.. not a OS-X specific Fn

              The system() function is ANSI C and thus on topic by any conceivable
              definition of on-topic. However how it is implemented is system
              specific.

              On any Unix, the string will be given to shell in a child process
              for the shell to deal with; the system() function waits for child
              exit and returns exit code. Any files have to be in the shell
              command string.

              --
              SM Ryan http://www.rawbw.com/~wyrmwif/
              So....that would make Bethany part black?

              Comment

              Working...