PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > 'which` command
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

'which` command

Réponse
 
LinkBack Outils de la discussion
Vieux 19/07/2007, 13h44   #1
sangeethabvn@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 'which` command

Hi all,

I have one setup in my .profile ie (along with the normal set/
alias...etc)
export ENV=${HOME}/.profile

inorder to run my profile file whenever i want to change into korn
shell. But interesting think is .profile is also executed when i run
'which' command

$which ls
Setting .profile.mine ....
$

I just want to know why ".profile" is execute whenever i run `which`
command.

Regards,
San.

  Réponse avec citation
Vieux 19/07/2007, 17h40   #2
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

On 2007-07-19, sangeethabvn@gmail.com wrote:
> Hi all,
>
> I have one setup in my .profile ie (along with the normal set/
> alias...etc)
> export ENV=${HOME}/.profile
>
> inorder to run my profile file whenever i want to change into korn
> shell. But interesting think is .profile is also executed when i run
> 'which' command
>
> $which ls
> Setting .profile.mine ....
> $
>
> I just want to know why ".profile" is execute whenever i run `which`
> command.


Which version of which are you using?

What does the man page say?

Why use which? What's wrong with type?


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 20/07/2007, 12h15   #3
sangeethabvn@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

I have found the answer for my question. Actually, my default login
shell is csh, i'm having "/bin/ksh" in the .cshrc. It looks like '
which' command executes ".cshrc" whenever I type ' which ' command.
( I've traced the ' which ' command's exection flow, by adding "echo"
statments in all these files)

On Jul 19, 9:40 pm, "Chris F.A. Johnson" <cfajohn...@gmail.com> wrote:
> On 2007-07-19, sangeetha...@gmail.com wrote:
> > Hi all,

>
> > I have one setup in my .profile ie (along with the normal set/
> > alias...etc)
> > export ENV=${HOME}/.profile

>
> > inorder to run my profile file whenever i want to change into korn
> > shell. But interesting think is .profile is also executed when i run
> > 'which' command

>
> > $which ls
> > Setting .profile.mine ....
> > $

>
> > I just want to know why ".profile" is execute whenever i run `which`
> > command.

>
> Which version of which are you using?
>
> What does the man page say?
>
> Why use which? What's wrong with type?
>
> --
> Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> ===== My code in this post, if any, assumes the POSIX locale
> ===== and is released under the GNU General Public Licence- Hide quoted text -
>
> - Show quoted text -



  Réponse avec citation
Vieux 21/07/2007, 04h24   #4
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

In article <1184930134.503419.175460@d30g2000prg.googlegroups .com>,
sangeethabvn@gmail.com wrote:

> I have found the answer for my question. Actually, my default login
> shell is csh, i'm having "/bin/ksh" in the .cshrc. It looks like '
> which' command executes ".cshrc" whenever I type ' which ' command.
> ( I've traced the ' which ' command's exection flow, by adding "echo"
> statments in all these files)


'which' is a C shell script, and it executes .cshrc to ensure that its
environment (in particular, $PATH) will be the same as an interactive
shell, so that it can tell you where in your $PATH it finds the command.

>
> On Jul 19, 9:40 pm, "Chris F.A. Johnson" <cfajohn...@gmail.com> wrote:
> > On 2007-07-19, sangeetha...@gmail.com wrote:
> > > Hi all,

> >
> > > I have one setup in my .profile ie (along with the normal set/
> > > alias...etc)
> > > export ENV=${HOME}/.profile

> >
> > > inorder to run my profile file whenever i want to change into korn
> > > shell. But interesting think is .profile is also executed when i run
> > > 'which' command

> >
> > > $which ls
> > > Setting .profile.mine ....
> > > $

> >
> > > I just want to know why ".profile" is execute whenever i run `which`
> > > command.

> >
> > Which version of which are you using?
> >
> > What does the man page say?
> >
> > Why use which? What's wrong with type?
> >
> > --
> > Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
> > Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> > ===== My code in this post, if any, assumes the POSIX locale
> > ===== and is released under the GNU General Public Licence- Hide quoted
> > text -
> >
> > - Show quoted text -


--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Vieux 23/07/2007, 09h27   #5
Eric
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

Chris F.A. Johnson wrote:

> On 2007-07-19, sangeethabvn@gmail.com wrote:
>> Hi all,
>>
>> I have one setup in my .profile ie (along with the normal set/
>> alias...etc)
>> export ENV=${HOME}/.profile
>>
>> inorder to run my profile file whenever i want to change into korn
>> shell. But interesting think is .profile is also executed when i run
>> 'which' command
>>
>> $which ls
>> Setting .profile.mine ....
>> $
>>
>> I just want to know why ".profile" is execute whenever i run `which`
>> command.

>
> Which version of which are you using?
>
> What does the man page say?
>



> Why use which? What's wrong with type?
>
>

Well, i like "which" because i can do this:
vi `which somescript.sh`
In our env some of the stuff is in rather long paths.
The PATH var is quite long,(its a specialized testing environment)
and the directory structure not so well thought out, so using the above
trick i can bring it up in vi rather easily without having to know where
some bonehead put the fool thing.
Eric

  Réponse avec citation
Vieux 23/07/2007, 14h13   #6
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

On 23 Jul., 10:27, Eric <No...@invalid.com> wrote:
> Chris F.A. Johnson wrote:
> > On 2007-07-19, sangeetha...@gmail.com wrote:
> >> Hi all,

>
> >> I have one setup in my .profile ie (along with the normal set/
> >> alias...etc)
> >> export ENV=${HOME}/.profile

>
> >> inorder to run my profile file whenever i want to change into korn
> >> shell. But interesting think is .profile is also executed when i run
> >> 'which' command

>
> >> $which ls
> >> Setting .profile.mine ....
> >> $

>
> >> I just want to know why ".profile" is execute whenever i run `which`
> >> command.

>
> > Which version of which are you using?

>
> > What does the man page say?

>
> > Why use which? What's wrong with type?

>
> Well, i like "which" because i can do this:
> vi `which somescript.sh`
> In our env some of the stuff is in rather long paths.


Either have a look at possible options to 'type' in your environment
to omit the prefix string "<prg> is [cached] ..." in the output, or,
since you use ksh, have a look at the 'whence' command instead.

Janis

> The PATH var is quite long,(its a specialized testing environment)
> and the directory structure not so well thought out, so using the above
> trick i can bring it up in vi rather easily without having to know where
> some bonehead put the fool thing.
> Eric



  Réponse avec citation
Vieux 23/07/2007, 20h36   #7
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

On 2007-07-23, Eric wrote:
> Chris F.A. Johnson wrote:
>
>> On 2007-07-19, sangeethabvn@gmail.com wrote:
>>> Hi all,
>>>
>>> I have one setup in my .profile ie (along with the normal set/
>>> alias...etc)
>>> export ENV=${HOME}/.profile
>>>
>>> inorder to run my profile file whenever i want to change into korn
>>> shell. But interesting think is .profile is also executed when i run
>>> 'which' command
>>>
>>> $which ls
>>> Setting .profile.mine ....
>>> $
>>>
>>> I just want to know why ".profile" is execute whenever i run `which`
>>> command.

>>
>> Which version of which are you using?
>>
>> What does the man page say?

>
>> Why use which? What's wrong with type?
>>

> Well, i like "which" because i can do this:
> vi `which somescript.sh`
> In our env some of the stuff is in rather long paths.
> The PATH var is quite long,(its a specialized testing environment)
> and the directory structure not so well thought out, so using the above
> trick i can bring it up in vi rather easily without having to know where
> some bonehead put the fool thing.


In bash I can do:

emacsclient `type -p somescript.sh`

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 24/07/2007, 13h40   #8
Geoff Clare
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

Janis wrote:

>> Well, i like "which" because i can do this:
>> vi `which somescript.sh`
>> In our env some of the stuff is in rather long paths.

>
> Either have a look at possible options to 'type' in your environment
> to omit the prefix string "<prg> is [cached] ..." in the output, or,
> since you use ksh, have a look at the 'whence' command instead.


Or just use "command -v" which is POSIX/SUS standard.

--
Geoff Clare <netnews@gclare.org.uk>
  Réponse avec citation
Vieux 24/07/2007, 13h40   #9
Geoff Clare
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'which` command

Janis wrote:

>> Well, i like "which" because i can do this:
>> vi `which somescript.sh`
>> In our env some of the stuff is in rather long paths.

>
> Either have a look at possible options to 'type' in your environment
> to omit the prefix string "<prg> is [cached] ..." in the output, or,
> since you use ksh, have a look at the 'whence' command instead.


Or just use "command -v" which is POSIX/SUS standard.

--
Geoff Clare <netnews@gclare.org.uk>
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h56.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19938 seconds with 17 queries