Can i know who has issued a comand?

S

Sumit Chawla

Hi all

I want to implement some functionality in rm command. But i want this
functionality to be there only when the user has inetractively issued
the command on the prompt.

For example : The added functiona should not get invoked when some
Kernel / or User script ,or Some package's ./configure or make clean
command is called.
This extra functinality should be called only when rm is issued by user
on CLI. Morover i need to hookup that rm command. i.e My function
should be called before rm perfroms the deletion.

I have tried the option of making changes to rm code itself , or making
alias entries in .bashrc file.

Is there any other way?

Please guide.

Regards
Sumit Chawla("eNetra")
Slogan:"Hail The Invention"
 
W

Walter Roberson

I want to implement some functionality in rm command. But i want this
functionality to be there only when the user has inetractively issued
the command on the prompt.

That is not a C topic, that is a topic specific to your OS
(which you still haven't mentioned, even though I hinted about this
point before.)

For example : The added functiona should not get invoked when some
Kernel / or User script ,or Some package's ./configure or make clean
command is called.
This extra functinality should be called only when rm is issued by user
on CLI. Morover i need to hookup that rm command. i.e My function
should be called before rm perfroms the deletion.

Let me see if I have this straight:

$ rm /tmp/foo # invoke extra functionality
$ sh <<EOF
rm /tmp/foo
EOF # do not invoke extra, this is a script
$ sh -c "rm /tmp/foo" # do not invoke extra, this is script
$ ( rm /tmp/foo ) # this is a mini-script too, so no extra functionality
$ touch /tmp/foo; rm /tmp/foo # I'd say this is a script
$ \rm /tmp/foo # not a script, invoke extra thou aliases disabled
$ /bin/rm /tmp/foo # not a script, invoke extra though real rm called direct

$ sh
$ # we are in an inner shell here
$ rm /tmp/foo # is this a script or is this interactive ?
$ exit
$ # back to original shell

I have tried the option of making changes to rm code itself , or making
alias entries in .bashrc file.
Is there any other way?

My personal opinion: give it up as a bad idea.
 
J

Jaspreet

Sumit said:
Hi all

I want to implement some functionality in rm command. But i want this
functionality to be there only when the user has inetractively issued
the command on the prompt.

For example : The added functiona should not get invoked when some
Kernel / or User script ,or Some package's ./configure or make clean
command is called.
This extra functinality should be called only when rm is issued by user
on CLI. Morover i need to hookup that rm command. i.e My function
should be called before rm perfroms the deletion.

I have tried the option of making changes to rm code itself , or making
alias entries in .bashrc file.

Dont try making any change to the rm code. You will surely break
something and how would you ensure that the target machine also gets
the rm code modified. If I were one of your target users and you would
come telling me that you need to modify rm code at my machine, I would
rather not use that product of yours.
Is there any other way?

Please guide.

Regards
Sumit Chawla("eNetra")
Slogan:"Hail The Invention"

Again an OT here. Go look for unix specific newsgroups.
 
K

Keith Thompson

Sumit Chawla said:
I want to implement some functionality in rm command. But i want this
functionality to be there only when the user has inetractively issued
the command on the prompt.

[...]

This is off-topic in comp.lang.c.

However, it's an appropriate question for comp.unix.shell. I see that
you posted the same question there almost simultaneously (and I've
responded there).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top