series of programes which are to be executed in other user's permissions

I have series of programe which are to be executed in other user's permissions.

ex :

  1. Two programes : programe1 and programe2.

  2. Logged into the server as a user say "sri"

  3. If I execute the programes system shows with "sri" owner.

    sri ohter programe1
    sri other programe2

  4. I have sudo permissions, if I run with sudo system shows "root"

  5. But i want to take the permission as "kanth" (which is other user)

    can i user any command like "su" with parameter

Any help would be greatly appreciated.

This should be possible. See man su

su -l kanth -c "programe1"

Another way: You may set the SUID bit to those programs, owned by the user you want them to be run as. So, if you have programe1 and programe2, and want them to be run as user1 then:

user2> ls -l programe1 programe2
-rwsr-xr-x   1 user1     user1            0 Jan 17 11:26 programe1
-rwsr-xr-x   1 user1     user1            0 Jan 17 11:26 programe2
user2> ./programe1

I do not kike to use SUID unless it's necessary, but it's a possible and easy solution.

Dear vino,

su -1 "kanth" -c "programe1" this options is not working as system gives an error "usage: su [ - ] user [sh options]"

Dear griel

SUID can not be set becasue all are application related programe.

the l in -l is the alphabet l (el) and not the digit 1

yes i tried with both the option "1 and l"

su -l kanth -c "programe1" which gives "usage: su [ - ] user [sh options]" 

error.

i tried with

su kanth -lc "programe1" which asks password ( which i don't know)

pls help me out on this

Anyway,

su - kanth -c "programe1"

(without "-l") is enough for my su...

Why? You just need to change the owner and set the bit... Perhaps you mean you don't have the possibility to do this, right?
Regards.

The password prompt comes up if you are currently not the root user.

Post the output of uname -a

yes , you are right i logged into as "sri" but i have sudo permission.

i can execute root commands by using "sudo"

ex:

sudo chmod kanth:kanth *

o/p of uname -a

UNIX_ser UNIX_ser 4.0 3.0 3516 Pentium IV(TM)-ISA/PCI

then:

sudo su - kanth -c "programe1"

assuming you are allowed to do that (sudoers).

Ah! Very dangerous: "sudo chmod kanth:kanth *" :smiley:

sudo chmod kanth:kanth *

yes , i never use it ..just i gave an example...

still i am getting same error

su kanth -c <program>

no - required after su

just try this

su kanth -c program 

it asks password which i don't know but i have sudo permissions