cancel
Showing results for 
Search instead for 
Did you mean: 

ux shell and c language

 
SOLVED
Go to solution
Highlighted
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
Highlighted
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);
}
Highlighted
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
Highlighted
SILVERSTAR
Frequent Advisor

Re: ux shell and c language

Hi,

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

Problem fixed

Thanks
Angelo