Allan Wind wrote:
> cd does not seem to do its thing when stdout is redirected to a pipe,
> however it does work with a (temporary) file:
Actually, cd does do its thing--it's just that its thing applies to the
subprocess
shell in the pipe instead of the shell it would normally apply to (when no
Stefan Schmidt wrote:
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
'cd' is a shell "builtin" command. In 'bash' and 'ksh', you can
r
> 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
I ultimately came up with this variant:
#!/bin/bash
LOG_FILE="/home/stefan/log/output.log"
TEMP_LOG="/home/stefan/log/temp.l
On Mon, Jul 14, 2008 at 12:34:08AM -, Cameron Hutchison wrote:
> "Stefan Schmidt" <[EMAIL PROTECTED]> writes:
>
> >> >if I pipe the output of a cd command the working directory doesn't
> >> change.
What are you trying to do ?
maybe something like
( cd ; do something else ) |
there is al
"Stefan Schmidt" <[EMAIL PROTECTED]> writes:
>> >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 i
> >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. T
"Stefan Schmidt" <[EMAIL PROTECTED]> 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
> 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 [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
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
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
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 c
> > ,
> > | $ 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 err
On Sun, Jul 13, 2008 at 20:22:24 +0200, Stefan Schmidt ([EMAIL PROTECTED])
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
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 [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Con
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 [EMAIL PROTECTED]
with a
15 matches
Mail list logo