Mike
Mike

Reputation: 3

Command in Xcode for tar.gz?

I am trying to make a simple command line tool in Xcode, that will allow me to make a tar.gz out of a specific folder. I want to see if i can make a program to autorun the command line, instead of typing it in every time i want to make a tar.gz out of something.

int main (int argc, const char * argv[]) {

// insert code here...

tar czvf SealTeamSix.tar.gz /Users/mdonovan14/Blah

return 0;
}

I understand that i am not setting this up right. How would i go about doing this?

Upvotes: 0

Views: 1372

Answers (2)

Abizern
Abizern

Reputation: 150615

Have a look at NSTask which lets you run command-line programs

Upvotes: 1

Caleb
Caleb

Reputation: 125007

You'd be better off using Automator to create a script that runs that snippet of shell script. Do the following:

  1. Launch Automator.
  2. Choose the Application template.
  3. Drag a Run Shell Script action into the work flow.
  4. Paste your script into text field.
  5. Save your new application, giving it a useful name.
  6. Switch to the Finder and run your app.
  7. Profit!

As it is, you're trying to mix shell scripting into a C program. You can certainly run shell scripts from C using the system() function, but using Automator here as described above is a much friendlier process.

Upvotes: 1

Related Questions