Calling System Command in SUN C 
Author Message
 Calling System Command in SUN C

I was wondering if anyone could help me with this problem.

I am new to SUN C and am using version 3.0.1.

I would like to execute a system command such as mail or a shell
script I have generated and was wondering if anyone knew of an easy
way to do this within C.

Thanks
Ed Thomson
Systems Coordinator
CINAHL Information Systems

WWW   : http://www.*-*-*.com/
Phone : 818-409-8007 x5330
Fax   : 818-956-7680



Fri, 28 Aug 1998 03:00:00 GMT  
 Calling System Command in SUN C

Quote:

> I was wondering if anyone could help me with this problem.
> I am new to SUN C and am using version 3.0.1.
> I would like to execute a system command such as mail or a shell
> script I have generated and was wondering if anyone knew of an easy
> way to do this within C.

The system(3S) function does what you want.  You pass it a string
which is the command to execute.  It returns the exit status of
the command.
--

Opinions are my own.  I don't speak for 3M.
    But 3M speaks for me -- I did not write the following line:

Opinions expressed herein are my own and may not represent those of 3M.



Sat, 29 Aug 1998 03:00:00 GMT  
 Calling System Command in SUN C

Quote:

>> I am new to SUN C and am using version 3.0.1.
>> I would like to execute a system command such as mail or a shell
>> script I have generated and was wondering if anyone knew of an easy
>> way to do this within C.

>The system(3S) function does what you want.  You pass it a string
>which is the command to execute.  It returns the exit status of
>the command.

Close - the exit status you want is in the 8 high-order bits of the return
value. On the Sun, you need to do something like

{
    int status;

    errno = 0;
    status = system(cmd);
    if (status == 127)
        return(-1);
    return(status>>8);

Quote:
}

--
David Byrne, Abacus Software, London, UK              Tel: +44 (0)171 603 9877

Here's a koan: If you have ice-cream I will give you some. If you have none,
               I will take it away from you. (it's an ice-cream koan).


Mon, 31 Aug 1998 03:00:00 GMT  
 Calling System Command in SUN C

I'm not sure if this will work for you, but does Sun C support the
"system" command?  Here's the syntax:  int system(char *cmd);  The return
value is the exit code of the cmd.  Hope this helps.
-----------------
Sandeep V. Tamhankar
Analysis Technician
Signaling Capabilities Analysis




Tue, 01 Sep 1998 03:00:00 GMT  
 Calling System Command in SUN C

Quote:


>>The system(3S) function does what you want.  You pass it a string
>>which is the command to execute.  It returns the exit status of
>>the command.
>Close - the exit status you want is in the 8 high-order bits of the return
>value. On the Sun, you need to do something like

[code snipped]

        Aren't the macros from sys/wait.h a more portable way to
extract the exit status?

--

Heed the words of the dead, for they are the least likely to
be trying to get something from you.



Tue, 01 Sep 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. system call in Sun OS - need help

2. system call on NT when spaces in command

3. hiding the command prompt during a system call

4. Newbie: separate big .cs file into small .cs files

5. what is the cshell command in sun corresponding to mktemp in HP.

6. Calling classes in other cs files

7. C compiler bug on 4.3BSD, Ultrix, Sun 3.2, System V.2

8. directing unix system call "system"s output

9. "system()" system call

10. calling fortran suns from c

11. Help: SUN Spark-calling Fortran functions

12. gcc c calls f77 fortran on Sun OS 4.1

 

 
Powered by phpBB® Forum Software