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 > result of `which ./a.sh`
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

result of `which ./a.sh`

Réponse
 
LinkBack Outils de la discussion
Vieux 25/04/2008, 02h35   #1
troyzeng
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut result of `which ./a.sh`

How to explain the following?
$ pwd
/home/user1
$ which ./a.sh
../a.sh
$ which ./a.sh | grep '.*'
/home/user1/a.sh
$ which ./a.sh | tee /dev/null
/home/user1/a.sh

It gives the full path as long as it's piped.
  Réponse avec citation
Vieux 25/04/2008, 02h55   #2
mop2
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: result of `which ./a.sh`

Please, redo and confirm:
$ which ./a.sh
../a.sh

If yes, and this:
$ which ./a.sh | cat


troyzeng wrote:
> How to explain the following?
> $ pwd
> /home/user1
> $ which ./a.sh
> ./a.sh
> $ which ./a.sh | grep '.*'
> /home/user1/a.sh
> $ which ./a.sh | tee /dev/null
> /home/user1/a.sh
>
> It gives the full path as long as it's piped.

  Réponse avec citation
Vieux 25/04/2008, 03h53   #3
troyzeng
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: result of `which ./a.sh`

On 25 Apr, 11:55, mop2 <mop2bky4mz5tyjwa8ersp7hrg5u...@gmail.com>
wrote:
> Please, redo and confirm:
> $ which ./a.sh
> ./a.sh
>
> If yes, and this:
> $ which ./a.sh | cat
>
> troyzeng wrote:
> > How to explain the following?
> > $ pwd
> > /home/user1
> > $ which ./a.sh
> > ./a.sh
> > $ which ./a.sh | grep '.*'
> > /home/user1/a.sh
> > $ which ./a.sh | tee /dev/null
> > /home/user1/a.sh

>
> > It gives the full path as long as it's piped.


$ which ./a.sh | cat
/home/user1/a.sh

It also returns the full path.
  Réponse avec citation
Vieux 25/04/2008, 07h31   #4
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: result of `which ./a.sh`

2008-04-24, 18:35(-07), troyzeng:
> How to explain the following?
> $ pwd
> /home/user1
> $ which ./a.sh
> ./a.sh

[...]

"which" is a non-standard command. You could get anything, there
exist a lot of implementations behaving differently.

Try "command -v" instead.

--
Stéphane
  Réponse avec citation
Vieux 26/04/2008, 17h02   #5
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: result of `which ./a.sh`

In article <slrng12ule.4qn.stephane.chazelas@spam.is.invalid> ,
Stephane CHAZELAS <this.address@is.invalid> wrote:
>2008-04-24, 18:35(-07), troyzeng:
>> How to explain the following?
>> $ pwd
>> /home/user1
>> $ which ./a.sh
>> ./a.sh

>[...]
>
>"which" is a non-standard command. You could get anything, there
>exist a lot of implementations behaving differently.
>
>Try "command -v" instead.


That don't work at all:

% command -v instead
command: Command not found.
%

  Réponse avec citation
Vieux 26/04/2008, 18h28   #6
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: result of `which ./a.sh`

2008-04-26, 16:02(+00), Kenny McCormack:
> In article <slrng12ule.4qn.stephane.chazelas@spam.is.invalid> ,
> Stephane CHAZELAS <this.address@is.invalid> wrote:
>>2008-04-24, 18:35(-07), troyzeng:
>>> How to explain the following?
>>> $ pwd
>>> /home/user1
>>> $ which ./a.sh
>>> ./a.sh

>>[...]
>>
>>"which" is a non-standard command. You could get anything, there
>>exist a lot of implementations behaving differently.
>>
>>Try "command -v" instead.

>
> That don't work at all:
>
> % command -v instead
> command: Command not found.

[...]

You forgot the quotes and the dot, and your prompt is incorrect:

$ "command -v" instead.
../a.sh

Having said that, it's true that csh and zsh will probably be
the shells with which "which" will work best as which at least
traditionnaly was only intended for csh users (as it was a csh
script reading the user's cshrc) and it's also built in zsh
(alias for "whence -c").

--
Stéphane
  Réponse avec citation
Vieux 26/04/2008, 19h47   #7
Kenny McCormack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: result of `which ./a.sh`

In article <slrng16pi8.919.stephane.chazelas@spam.is.invalid> ,
Stephane CHAZELAS <this.address@is.invalid> wrote:
>2008-04-26, 16:02(+00), Kenny McCormack:
>> In article <slrng12ule.4qn.stephane.chazelas@spam.is.invalid> ,
>> Stephane CHAZELAS <this.address@is.invalid> wrote:
>>>2008-04-24, 18:35(-07), troyzeng:
>>>> How to explain the following?
>>>> $ pwd
>>>> /home/user1
>>>> $ which ./a.sh
>>>> ./a.sh
>>>[...]
>>>
>>>"which" is a non-standard command. You could get anything, there
>>>exist a lot of implementations behaving differently.
>>>
>>>Try "command -v" instead.

>>
>> That don't work at all:
>>
>> % command -v instead
>> command: Command not found.

>[...]
>
>You forgot the quotes and the dot, and your prompt is incorrect:


My prompt is incorrect???

Are you saying that the code that you post is dependent on what the user
has set his prompt to? Bizarro!

  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 14h44.


É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,13173 seconds with 15 queries