Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using c tou run solaris command 2

Status
Not open for further replies.

moniema

IS-IT--Management
Apr 20, 2003
19
0
0
SD
Hello

Dear All,

Iam new to c programming and I was wondering how can I run a solaris command on c and also in scripting we can declare variables like:

setenv MM hello
and we can use it like :

echo $MM

how can this be done in c ??

I hope my question is not silly


Thannks in advance for your advices

Moniem
 
for running operating system commands:
man system

for using operating system environment variables:
man getenv

hope this helps
 
It's rather unclear question, but...
Code:
const char var[] = "MM";
const char* p = getenv(var);
char  cmd[1024];
if (p)
{
   strcpy(cmd,"echo ");
   strcat(cmd,p);
   system(cmd);
}
else
   printf("Alas, no %s\n",var);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top