|
|
|
|
||||||
| linux.debian.user debian-user@lists.debian.org. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Let's say I run a command in bash which is run via konsole. How can I view its exit status.
For example, if I do $test -x debian/rules I want to know if the command exited with status zero or non-zero. Can this be done in a simple way? thank for any suggestions raju ---------------------------------------------------------------------- Finally - A spam blocker that actually works. http://www.bluebottle.com/tag/4 -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Le Wednesday 15 August 2007, Kamaraju Kusumanchi(Kamaraju Kusumanchi
<kamaraju@bluebottle.com>) a écrit: Hi, > Let's say I run a command in bash which is run via konsole. How > can I view its exit status. > > For example, if I do > > $test -x debian/rules try: test -x debian/rules ; echo $? HTH, -- Glennie Vignarajah http://www.glennie.fr An undefined problem has an infinite number of solutions. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Le Wednesday 15 August 2007, Kamaraju Kusumanchi(Kamaraju Kusumanchi
<kamaraju@bluebottle.com>) a écrit: Hi, > Let's say I run a command in bash which is run via konsole. How > can I view its exit status. > > For example, if I do > > $test -x debian/rules try: test -x debian/rules ; echo $? HTH, -- Glennie Vignarajah http://www.glennie.fr An undefined problem has an infinite number of solutions. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Hi Kamaraju
On Wed, Aug 15, 2007 at 12:51:06AM -0700, Kamaraju Kusumanchi wrote: > Let's say I run a command in bash which is run via konsole. How can I view its exit status. > > For example, if I do > > $test -x debian/rules > > I want to know if the command exited with status zero or non-zero. Can this be done in a simple way? $test -x debian/rules; echo $? man bash: Special Parameters (...) ? Expands to the status of the most recently executed foreground pipeline. > > thank for any suggestions > raju > HTH -- Joachim Fahnenmüller -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Hi Kamaraju
On Wed, Aug 15, 2007 at 12:51:06AM -0700, Kamaraju Kusumanchi wrote: > Let's say I run a command in bash which is run via konsole. How can I view its exit status. > > For example, if I do > > $test -x debian/rules > > I want to know if the command exited with status zero or non-zero. Can this be done in a simple way? $test -x debian/rules; echo $? man bash: Special Parameters (...) ? Expands to the status of the most recently executed foreground pipeline. > > thank for any suggestions > raju > HTH -- Joachim Fahnenmüller -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Joachim Fahnenmüller wrote:
>> For example, if I do >> >> $test -x debian/rules >> >> I want to know if the command exited with status zero or non-zero. Can >> this be done in a simple way? > > $test -x debian/rules; echo $? > Thanks. Exactly what I am after! raju -- Kamaraju S Kusumanchi http://www.people.cornell.edu/pages/kk288/ http://malayamaarutham.blogspot.com/ -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Joachim Fahnenmüller wrote:
>> For example, if I do >> >> $test -x debian/rules >> >> I want to know if the command exited with status zero or non-zero. Can >> this be done in a simple way? > > $test -x debian/rules; echo $? > Thanks. Exactly what I am after! raju -- Kamaraju S Kusumanchi http://www.people.cornell.edu/pages/kk288/ http://malayamaarutham.blogspot.com/ -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Kamaraju S Kusumanchi <kamaraju@bluebottle.com> writes:
>>> I want to know if the command exited with status zero or non-zero. Can >>> this be done in a simple way? >> >> $test -x debian/rules; echo $? >> > > Thanks. Exactly what I am after! Here's a $0.02 recipe from my ~/.bashrc: if [ "$PS1" ]; then PROMPT_COMMAND='echo -n "$? "' fi This way, an interactive bash will print the exit status of the last command before its prompt, so you can _always_ see it. Very handy, IMO. :-) Cheers, Sven -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
Kamaraju S Kusumanchi <kamaraju@bluebottle.com> writes:
>>> I want to know if the command exited with status zero or non-zero. Can >>> this be done in a simple way? >> >> $test -x debian/rules; echo $? >> > > Thanks. Exactly what I am after! Here's a $0.02 recipe from my ~/.bashrc: if [ "$PS1" ]; then PROMPT_COMMAND='echo -n "$? "' fi This way, an interactive bash will print the exit status of the last command before its prompt, so you can _always_ see it. Very handy, IMO. :-) Cheers, Sven -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On Wed, Aug 15, 2007 at 04:21:17PM +0200, Sven Joachim wrote:
> Kamaraju S Kusumanchi <kamaraju@bluebottle.com> writes: > > >>> I want to know if the command exited with status zero or non-zero. Can > >>> this be done in a simple way? > >> > >> $test -x debian/rules; echo $? > >> > > > > Thanks. Exactly what I am after! > > Here's a $0.02 recipe from my ~/.bashrc: > > if [ "$PS1" ]; then > PROMPT_COMMAND='echo -n "$? "' > fi > > This way, an interactive bash will print the exit status of the last > command before its prompt, so you can _always_ see it. Very handy, > IMO. :-) Thanks for this great idea! -- Ken Irving, fnkci@uaf.edu -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
Ken Irving wrote:
> On Wed, Aug 15, 2007 at 04:21:17PM +0200, Sven Joachim wrote: > >> Kamaraju S Kusumanchi <kamaraju@bluebottle.com> writes: >> >> >>>>> I want to know if the command exited with status zero or non-zero. Can >>>>> this be done in a simple way? >>>>> >>>> $test -x debian/rules; echo $? >>>> >>>> >>> Thanks. Exactly what I am after! >>> >> Here's a $0.02 recipe from my ~/.bashrc: >> >> if [ "$PS1" ]; then >> PROMPT_COMMAND='echo -n "$? "' >> fi >> >> This way, an interactive bash will print the exit status of the last >> command before its prompt, so you can _always_ see it. Very handy, >> IMO. :-) >> > > Thanks for this great idea! > > You don't need a command (at least with the versions of bash I've used the last 10 years), just make sure the variable does not get expanded before it is assigned to PS1. Like so: PS1='$?\$ '. now try executing /bin/true and /bin/false. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
On Wed, Aug 15, 2007 at 09:42:16PM +0200, Håkon Alstadheim wrote:
> Ken Irving wrote: >> On Wed, Aug 15, 2007 at 04:21:17PM +0200, Sven Joachim wrote: >> >>> Kamaraju S Kusumanchi <kamaraju@bluebottle.com> writes: >>> >>> >>>>>> I want to know if the command exited with status zero or non-zero. Can >>>>>> this be done in a simple way? >>>>>> >>>>> $test -x debian/rules; echo $? >>>>> >>>>> >>>> Thanks. Exactly what I am after! >>>> >>> Here's a $0.02 recipe from my ~/.bashrc: >>> >>> if [ "$PS1" ]; then >>> PROMPT_COMMAND='echo -n "$? "' >>> fi >>> >>> This way, an interactive bash will print the exit status of the last >>> command before its prompt, so you can _always_ see it. Very handy, >>> IMO. :-) >>> >> >> Thanks for this great idea! >> >> > > You don't need a command (at least with the versions of bash I've used the > last 10 years), just make sure the variable does not get expanded before it > is assigned to PS1. Like so: PS1='$?\$ '. now try executing /bin/true and > /bin/false. Right, I was referring to including the exit value in the prompt. I usually prefer to have a two-line prompt so I can see my current path, which sometimes gets unwieldy; e.g., PS1='\u@\h:\w/\n$?\$ ' results in ken@hayes:~/proj/source/perl/thinobject/tob-lib/BaseClass/ 0$ Ken -- Ken Irving, fnkci@uaf.edu -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
On Wed, Aug 15, 2007 at 09:42:16PM +0200, Håkon Alstadheim wrote:
> Ken Irving wrote: >> On Wed, Aug 15, 2007 at 04:21:17PM +0200, Sven Joachim wrote: >> >>> Kamaraju S Kusumanchi <kamaraju@bluebottle.com> writes: >>> >>> >>>>>> I want to know if the command exited with status zero or non-zero. Can >>>>>> this be done in a simple way? >>>>>> >>>>> $test -x debian/rules; echo $? >>>>> >>>>> >>>> Thanks. Exactly what I am after! >>>> >>> Here's a $0.02 recipe from my ~/.bashrc: >>> >>> if [ "$PS1" ]; then >>> PROMPT_COMMAND='echo -n "$? "' >>> fi >>> >>> This way, an interactive bash will print the exit status of the last >>> command before its prompt, so you can _always_ see it. Very handy, >>> IMO. :-) >>> >> >> Thanks for this great idea! >> >> > > You don't need a command (at least with the versions of bash I've used the > last 10 years), just make sure the variable does not get expanded before it > is assigned to PS1. Like so: PS1='$?\$ '. now try executing /bin/true and > /bin/false. Right, I was referring to including the exit value in the prompt. I usually prefer to have a two-line prompt so I can see my current path, which sometimes gets unwieldy; e.g., PS1='\u@\h:\w/\n$?\$ ' results in ken@hayes:~/proj/source/perl/thinobject/tob-lib/BaseClass/ 0$ Ken -- Ken Irving, fnkci@uaf.edu -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#14 |
|
Messages: n/a
Hébergeur: |
Håkon Alstadheim <hakon@alstadheim.priv.no> writes:
> You don't need a command (at least with the versions of bash I've used > the last 10 years), just make sure the variable does not get expanded > before it is assigned to PS1. Like so: PS1='$?\$ '. now try executing > /bin/true and /bin/false. Indeed, thanks for enlightening me. I've had this PROMPT_COMMAND for a few years, never noticed that it is not necessary. Cheers, Sven -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#15 |
|
Messages: n/a
Hébergeur: |
Håkon Alstadheim <hakon@alstadheim.priv.no> writes:
> You don't need a command (at least with the versions of bash I've used > the last 10 years), just make sure the variable does not get expanded > before it is assigned to PS1. Like so: PS1='$?\$ '. now try executing > /bin/true and /bin/false. Indeed, thanks for enlightening me. I've had this PROMPT_COMMAND for a few years, never noticed that it is not necessary. Cheers, Sven -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#16 |
|
Messages: n/a
Hébergeur: |
It only takes one line appended to a shell script:
echo $_ >status.log -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
![]() |
| Outils de la discussion | |
|
|