473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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!

Jul 28 '07 #1
6 3676
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.programming>

<snip>

Jul 28 '07 #2
On Jul 28, 1:32 pm, sushi boi <sushant...@gmail.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.

Jul 28 '07 #3
sushi boi <su********@gmail.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
Jul 28 '07 #4
santosh <sa*********@gmail.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.programming>
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_Keith) ks***@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"
Jul 28 '07 #5
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

Jul 30 '07 #6
sushi boi <su********@gmail.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?
Jul 30 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
6
by: Lauren Wilson | last post by:
Hi folks, In an A2K app, I have attempted to use the following command in some VBA code with IDENTICAL results with every single version of the following: Shell "outlook.exe", vbHide Shell...
1
by: VRWC | last post by:
Hello dear people, In an A2K app, I have attempted to use the following command in some VBA code with IDENTICAL results with every single version of the following: Shell "outlook.exe", vbHide...
8
by: zhiwei wang | last post by:
I remember that there is a function that could invoke shell command such as "rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely...
2
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
3
by: ppuniversal | last post by:
Hi everyone, I am making using Shell() function to run a command line tool from my VB Application. I am using it to archive a folder. So I am using the code : Shell("command line argument as...
1
by: raocheng | last post by:
Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.