[comp.unix.questions] Interfacing C and UNIX in SunView?

jasonf@cetemp.Eng.Sun.COM (Jason Freund) (07/31/90)

	I'm writing a C program in the SunView 4.0 environment.  My
program will, eventually, open up in its own window (using a SunView function)
and do some stuff (like manipulate files).  I want my C program to be able to 
to execute simple UNIX command sequences from inside its SunView window to 
make my programming job much easier -- like "lpr -<printer> <file>", 
"rm <file>", etc. so that I don't have to write equivalents in C.  Speed is 
not a factor, but the fact that the program uses the shell (or it opens a new 
window and uses its shell) should be hidden as much as possible.  Is this 
possible?  Or should I look into file manipulation in the SunView programmers 
guide?  Is interfacing C and UNIX independant of the environment (SunView) I 
work in?


Thanks,
Jason Freund

jik@athena.mit.edu (Jonathan I. Kamens) (08/01/90)

  (Note the Followup-To, which *should* have been included with the original
article.  The article doesn't belong in comp.unix.wizards in any case.  Heck,
it shouldn't have even been posted to the net, considering that the original
poster could have found out the answers to his questions by typing "man -k
execute", or "man -k command", or by asking a more knowledgeable programmer at
his site (the best solution).)

In article <139856@sun.Eng.Sun.COM>, jasonf@cetemp.Eng.Sun.COM (Jason Freund) writes:
|> 
|> 	I'm writing a C program in the SunView 4.0 environment.  My
|> program will, eventually, open up in its own window (using a SunView function)
|> and do some stuff (like manipulate files).  I want my C program to be able to 
|> to execute simple UNIX command sequences from inside its SunView window to 
|> make my programming job much easier -- like "lpr -<printer> <file>", 
|> "rm <file>", etc. so that I don't have to write equivalents in C.  Speed is 
|> not a factor, but the fact that the program uses the shell (or it opens a new 
|> window and uses its shell) should be hidden as much as possible.

  See the man pages in section 3 of the manual for the library functions
system() and execl().  For example, system("lpr -<printer> <file>"); will
execute the lpr command.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710