FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 07-13-2008, 06:22 PM
"Stefan Schmidt"
 
Default Bash: pipe once more

Hello,

if I pipe the output of a cd command the working directory doesn't change.

,----
| $ cd ~/bin 2>&1 | tee -a output.log; pwd
| /home/stefan
`----

How come and how can I get this to work?

Stefan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 06:33 PM
"Stefan Schmidt"
 
Default Bash: pipe once more

Hello,

if I pipe the output of a cd command the working directory doesn't change.

,----
| $ cd ~/bin 2>&1 | tee -a output.log; pwd
| /home/stefan
`----

How come and how can I get this to work?

Stefan

P.S. Sorry if this gets double-posted


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 06:48 PM
Bob Cox
 
Default Bash: pipe once more

On Sun, Jul 13, 2008 at 20:22:24 +0200, Stefan Schmidt (Stefan.Schmidt@gmx.de) wrote:

> if I pipe the output of a cd command the working directory doesn't change.

Hi Stefan

Assuming your cd command takes you to a valid directory, then there
seems to be no output to pipe...

> ,----
> | $ cd ~/bin 2>&1 | tee -a output.log; pwd
> | /home/stefan
> `----
>
> How come and how can I get this to work?

Sorry, but I am not sure quite what you are trying to achieve. Maybe I
am missing the point!

--
Bob Cox. Stoke Gifford, near Bristol, UK.
Registered user #445000 with the Linux Counter - http://counter.li.org/


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Sun Jul 13 22:30:01 2008
Return-path: <ubuntu-users-bounces@lists.ubuntu.com>
Envelope-to: tom@linux-archive.org
Delivery-date: Sun, 13 Jul 2008 21:53:55 +0300
Received: from chlorine.canonical.com ([91.189.94.204])
by s2.java-tips.org with esmtp (Exim 4.69)
(envelope-from <ubuntu-users-bounces@lists.ubuntu.com>)
id 1KI6hm-0000UG-SJ
for tom@linux-archive.org; Sun, 13 Jul 2008 21:53:55 +0300
Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com)
by chlorine.canonical.com with esmtp (Exim 4.60)
(envelope-from <ubuntu-users-bounces@lists.ubuntu.com>)
id 1KI6gU-0004qA-VI; Sun, 13 Jul 2008 19:52:34 +0100
Received: from infogerance.us ([213.251.184.201] helo=www.infogerance.us)
by chlorine.canonical.com with esmtp (Exim 4.60)
(envelope-from <mihamina.rakotomandimby@etu.univ-orleans.fr>)
id 1KI6gS-0004pw-N4
for ubuntu-users@lists.ubuntu.com; Sun, 13 Jul 2008 19:52:32 +0100
Received: from cgprs.orangenet.mg ([80.12.72.20] helo=[192.168.0.201])
by www.infogerance.us with esmtpa (Exim 4.67)
(envelope-from <mihamina.rakotomandimby@etu.univ-orleans.fr>)
id 1KI5pJ-0001h3-Fw
for ubuntu-users@lists.ubuntu.com; Sun, 13 Jul 2008 19:57:40 +0200
Message-ID: <487A4ED4.4000904@etu.univ-orleans.fr>
Date: Sun, 13 Jul 2008 21:52:04 +0300
From: "Mihamina Rakotomandimby (R12y)"
<mihamina.rakotomandimby@etu.univ-orleans.fr>
User-Agent: Thunderbird 2.0.0.14 (X11/20080505)
MIME-Version: 1.0
To: ubuntu-users@lists.ubuntu.com
Subject: atl1, hardy, more than 4GB of RAM
X-BeenThere: ubuntu-users@lists.ubuntu.com
X-Mailman-Version: 2.1.8
Precedence: list
Reply-To: "Ubuntu user technical support,
not for general discussions" <ubuntu-users@lists.ubuntu.com>
List-Id: "Ubuntu user technical support,
not for general discussions" <ubuntu-users.lists.ubuntu.com>
List-Unsubscribe: <https://lists.ubuntu.com/mailman/listinfo/ubuntu-users>,
<mailto:ubuntu-users-request@lists.ubuntu.com?subject=unsubscribe>
List-Archive: <https://lists.ubuntu.com/archives/ubuntu-users>
List-Post: <mailto:ubuntu-users@lists.ubuntu.com>
List-Help: <mailto:ubuntu-users-request@lists.ubuntu.com?subject=help>
List-Subscribe: <https://lists.ubuntu.com/mailman/listinfo/ubuntu-users>,
<mailto:ubuntu-users-request@lists.ubuntu.com?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: ubuntu-users-bounces@lists.ubuntu.com
Errors-To: ubuntu-users-bounces@lists.ubuntu.com

Hi,
I have an Asus motherboard shipping an Attlansic (atl1 module) on board
network card interface.
It's a brand new computer I put on my LAN in order to be a file server.
I noticed some network hangs and even system freezes after the beginning
of heavy network file transferts (via FTP, NFS and SSH).
I have other boxes on the LAN and tested the trasnfert with them, no
problems: the problen is really the card with the "atl1" module.

Searching on Google, I saw:
http://atl1.sourceforge.net/, saying:
KNOWN BUGS/PROBLEMS

1. [...]

2. There is a bug in the atl1 driver that results in a kernel hang or
crash (oops) under heavy network load IF AND ONLY IF you have 4GB or
more RAM in your system. This happens because of an L1 hardware design
issue that is exposed by the atl1 driver. If you encounter this
problem, modify your kernel's boot line and add this kernel parameter:
mem=3900M. A fix was added to the 2.6.23 kernel.

My system has 8GB of RAM, amd64 architecture and system (AMD Phenom
Quad), and as a file server, it has a heavy network load (7 XDMCP'd
workstations)

The quote mentions the bug is solved in the 2.6.23 and hardy (my system)
is running 2.6.24.

Have you got any information about that? Didn't the Ubuntu 2.6.24
include the solution of the problem?

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 07-13-2008, 06:55 PM
"Stefan Schmidt"
 
Default Bash: pipe once more

> > ,----
> > | $ cd ~/bin 2>&1 | tee -a output.log; pwd
> > | /home/stefan
> > `----
> >
> > How come and how can I get this to work?
>
> Sorry, but I am not sure quite what you are trying to achieve. Maybe I
> am missing the point!

I want to change the working directory and if there is an error (e.g. the directory doesn't exist) I want that to be logged to a file and printed on stdout. With the above command that doesn't work since the working directory is the same as before execution of the command.

Stefan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 07:19 PM
Eduardo M KALINOWSKI
 
Default Bash: pipe once more

Stefan Schmidt wrote:
> I want to change the working directory and if there is an error (e.g. the directory doesn't exist) I want that to be logged to a file and printed on stdout. With the above command that doesn't work since the working directory is the same as before execution of the command.
>

if [ ! -d some_path ] ; then
echo There was an error
echo There was an error >> log.txt
# There must be an intelligent way to combine the above two lines, but
I'm not in the mood to discover it right now.
exit 1;
fi

cd some_path


Warning: The above may contain bashisms.


--
"One Architecture, One OS" also translates as "One Egg, One Basket".

Eduardo M KALINOWSKI
eduardo@kalinowski.com.br
http://move.to/hpkb


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 07:21 PM
Allan Wind
 
Default Bash: pipe once more

On 2008-07-13T20:55:42+0200, Stefan Schmidt wrote:
> I want to change the working directory and if there is an error (e.g.
> the directory doesn't exist) I want that to be logged to a file and
> printed on stdout. With the above command that doesn't work since the
> working directory is the same as before execution of the command.

cd does not seem to do its thing when stdout is redirected to a pipe,
however it does work with a (temporary) file:

cd bad > cd.out 2>&1
cat cd.out
rm cd.out

Another way to go about this is to just do the cd, and write your own
error message if OLDPWD and PWD are the same.

Finally, you could check for the error conditions before doing the cd:

if [ -d $dir -a -x $dir ];
then
echo cannot cd into $dir
else
cd $dir
fi


/Allan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 07:22 PM
Allan Wind
 
Default Bash: pipe once more

On 2008-07-13T15:21:21-0400, Allan Wind wrote:
> Finally, you could check for the error conditions before doing the cd:
>
> if [ -d $dir -a -x $dir ];
> then
> echo cannot cd into $dir
> else
> cd $dir
> fi

Reverse the logic of course:

if [ -d $dir -a -x $dir ];
then
cd $dir
else
echo cannot cd into $dir
fi


/Allan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 09:03 PM
"Stefan Schmidt"
 
Default Bash: pipe once more

> cd does not seem to do its thing when stdout is redirected to a pipe,

Is this behaviour a bug or a feature?

Stefan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 10:54 PM
Cameron Hutchison
 
Default Bash: pipe once more

"Stefan Schmidt" <Stefan.Schmidt@gmx.de> writes:

>Hello,

>if I pipe the output of a cd command the working directory doesn't change.

That's because all elements of a pipeline except the last are run in
different processes to the main shell that starts the pipeline. As such,
the cd command is running in a subshell which exits when cd exits. This
has no effect on your main shell, which will keep the original working
directory.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-13-2008, 11:06 PM
"Stefan Schmidt"
 
Default Bash: pipe once more

> >if I pipe the output of a cd command the working directory doesn't
> change.
>
> That's because all elements of a pipeline except the last are run in
> different processes to the main shell that starts the pipeline. As such,
> the cd command is running in a subshell which exits when cd exits. This
> has no effect on your main shell, which will keep the original working
> directory.

Is there any way to change this behaviour?

Stefan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 07:06 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org