1753518 Members
5212 Online
108795 Solutions
New Discussion юеВ

ux shell and c language

 
SOLVED
Go to solution
SILVERSTAR
Frequent Advisor

ux shell and c language

Hi,

I need to kill a process owned by user1 from a user2.
The user2 access shell of user1 via a remote shell invoked by a c routine.
The problem is that the c routine does not see the variable "pidtokill".
Ho make this work ?

Many thanks
Angelo

#include
#include
#include

int pidtokill ;

main ()
{
printf ( "pid to killi ==> ");
scanf ("%d",&pidtokill);
system(
"remsh machine1 -l user1 \" kill &pidtokill \"" );
}

3 REPLIES 3
Simon Hargrave
Honored Contributor
Solution

Re: ux shell and c language

This should achieve what you're trying: -

#include
#include
#include

int pidtokill ;
char command[256];

main()
{
printf ( "pid to killi ==> ");
scanf ("%d",&pidtokill);
sprintf (&command,"remsh machine1 -l user1 \"kill %d\"",pidtokill);
system(command);
}
SILVERSTAR
Frequent Advisor

Re: ux shell and c language

Hi,

the result has been:
cc: "diespool2.c", line 12: warning 604: Pointers are not assignment-compatible.
cc: "diespool2.c", line 12: warning 563: Argument #1 is not the correct type.

Actually I am reading sprintf man page but cannot really understand where the error is.

Thanks for help

Thanks
Angelo
SILVERSTAR
Frequent Advisor

Re: ux shell and c language

Hi,

&command was an error.
Eliminating the & the job works

Problem fixed

Thanks
Angelo