Re: Probably very stupid script/bash question

2008-03-10 Thread Michelle Konzack
Am 2008-03-05 14:13:33, schrieb Brian:
 teststring=one two three four five six 
 { read A B C D E F; }  ( echo $teststring ) 
 echo Data received = $E Bytes 
 END OF REPLIED MESSAGE 

This look a little bit weird. Why not use:

8
read A B C D E F EOF
one two three four five six
EOF
8

and

8
teststring=one two three four five six 

read A B C D E F EOF
$teststring
EOF

echo Data received = $E Bytes 
8

no need for a stupid resources eating subschell expecialy on a ARM.

:-)


Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: Probably very stupid script/bash question

2008-03-10 Thread Michelle Konzack
Am 2008-03-05 13:10:37, schrieb Bob McGowan:
 Mark Clarkson wrote:
 On Wed, 05 Mar 2008 12:16:02 -0800
 Bob McGowan [EMAIL PROTECTED] wrote:
 
 Brian wrote:
 So can you explain exactly what the first  ( echo $teststring )
 does exactly please?

man bash

8--
echo EOD
   Here Documents
   This  type  of  redirection  instructs the shell to read input from the
   current source until a line containing  only  word  (with  no  trailing
   blanks)  is seen.  All of the lines read up to that point are then used
   as the standard input for a command.

   The format of here-documents is:

  [-]word
  here-document
  delimiter

   No parameter expansion, command substitution, arithmetic expansion,  or
   pathname expansion is performed on word.  If any characters in word are
   quoted, the delimiter is the result of quote removal on word,  and  the
   lines  in the here-document are not expanded.  If word is unquoted, all
   lines of the here-document are subjected to parameter  expansion,  com-
   mand  substitution,  and arithmetic expansion.  In the latter case, the
   character sequence \newline is ignored, and \ must be used  to  quote
   the characters \, $, and `.

   If the redirection operator is -, then all leading tab characters are
   stripped from input lines and  the  line  containing  delimiter.   This
   allows  here-documents within shell scripts to be indented in a natural
   fashion.
EOD
8--


Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
+49/177/935194750, rue de Soultz MSN LinuxMichi
+33/6/61925193 67100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: Probably very stupid script/bash question

2008-03-10 Thread Bob McGowan

Michelle Konzack wrote:

Am 2008-03-05 14:13:33, schrieb Brian:
teststring=one two three four five six 
{ read A B C D E F; }  ( echo $teststring ) 
echo Data received = $E Bytes 

 END OF REPLIED MESSAGE 

This look a little bit weird. Why not use:

8
read A B C D E F EOF
one two three four five six
EOF
8

and

8
teststring=one two three four five six 


read A B C D E F EOF
$teststring
EOF

echo Data received = $E Bytes 
8


no need for a stupid resources eating subschell expecialy on a ARM.

:-)



Actually, the example code is a trivial example used to illustrate how 
to use process substitution.  A real case might have a series of 
commands running, or a single large application, etc., from which you 
want to read the output in some asynchronous way.


In some cases, using a here doc would be an option, but in the cases 
mentioned above, you don't know what the text will be until you fetch 
it.  It's a run time issue.


--
Bob McGowan


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Probably very stupid script/bash question

2008-03-10 Thread Bob McGowan

Michelle Konzack wrote:

Am 2008-03-05 13:10:37, schrieb Bob McGowan:

Mark Clarkson wrote:

On Wed, 05 Mar 2008 12:16:02 -0800
Bob McGowan [EMAIL PROTECTED] wrote:


Brian wrote:

So can you explain exactly what the first  ( echo $teststring )
does exactly please?


man bash

8--

### deleted 'here' doc usage ###




The syntax ... (command ...) is *not* a here document.  You should 
refer back to the original discussion for details.


A brief synopsis is:  '(command ...)' will substitute the command 
output into a named piped, which is then read.  Using the second '', 
separated by white space, will then redirect input from the named pipe 
to a builtin command, such as read.


If you take the example command and remove the space between the two 
less than symbols, you get a syntax error.


--
Bob McGowan


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Probably very stupid script/bash question

2008-03-05 Thread Brian

Mark Clarkson wrote:

On Tue, 04 Mar 2008 18:46:05 +0100
Brian [EMAIL PROTECTED] wrote:


I could not get this to work, the shell complains:

./dirvish-mail.sh: 98: Syntax error: redirection unexpected



Interesting to note that this does not work under busybox. I think
this is rather an esoteric but often useful bash feature. (It also
needs /proc so is not available in some special cases.)


The other solution from Alex:

  echo $teststring | ( read A B C D E F; )

Of course, both solutions work perfectly under bash.



This should not have worked under bash either since it is still running
in a sub-shell, so the variables are lost when read finishes.



Mark,
of course you are correct. I had written the following test script:

=
#!/bin/bash 




teststring=one two three four five six 




{ read A B C D E F; }  ( echo $teststring ) 

echo Data received = $E Bytes 






echo $teststring | ( read A B C D E F; ) 


echo Data received = $E Bytes
=

$E was still set from the first read call. Duuh.

So can you explain exactly what the first  ( echo $teststring )
does exactly please?


Cheers Brian


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Probably very stupid script/bash question

2008-03-05 Thread Bob McGowan

Brian wrote:

Mark Clarkson wrote:

On Tue, 04 Mar 2008 18:46:05 +0100
Brian [EMAIL PROTECTED] wrote:


I could not get this to work, the shell complains:

./dirvish-mail.sh: 98: Syntax error: redirection unexpected



Interesting to note that this does not work under busybox. I think
this is rather an esoteric but often useful bash feature. (It also
needs /proc so is not available in some special cases.)


The other solution from Alex:

  echo $teststring | ( read A B C D E F; )

Of course, both solutions work perfectly under bash.



This should not have worked under bash either since it is still running
in a sub-shell, so the variables are lost when read finishes.



Mark,
of course you are correct. I had written the following test script:

=
#!/bin/bash


teststring=one two three four five six


{ read A B C D E F; }  ( echo $teststring )
echo Data received = $E Bytes




echo $teststring | ( read A B C D E F; )
echo Data received = $E Bytes
=

$E was still set from the first read call. Duuh.

So can you explain exactly what the first  ( echo $teststring )
does exactly please?


Cheers Brian




It looks like the construct ' (...)' is an undocumented (at least it's 
not in the man page for bash) feature that redirects the output of a 
command in such a way as to look like it's from a file.  I base this on 
the following observations:


1.  Reading the man page for bash, it states that if a builtin command 
(such as 'read') is used in a pipe, the command is run in a sub shell. 
This is why echo 1 2 3 | read A B C followed by echo $A $B $C prints 
only a blank line.  The assignment is in a sub shell and lost when 
execution comes back to the parent.


2.  If I have a file with more than one line in it and the first line 
has no white space, and I do this:


read A B C  file

The variable A will have the first line of the file in it, with all 
subsequent variables empty.  If the first line has white space, then as 
many variables as there are fields in the line will contain values.


3.  if I do this, using the ' (...)' construct with an echo that 
produces two lines:


{ read A B C D E F; }  ( echo -e one two three\nfour five )

The first three variables will have the first three values, but the last 
three variables will be empty.


4.  See 5, below.

Since this operator appears to follow the same rules as file 
redirection, it would seem logical to assume it mimics file type I/O 
redirection.  But this is a WAG ('wild ass guess' for those that don't 
know) and may be way off base.


In any case, I'd be interested in knowing where you found this construct.

Further, for those interested in actually using it, these are the rules 
I've figured out, so far:


1.  The format is exact, you must have one or more white spaces between 
the two 'less than' symbols and NO space between the 'less than' and the 
'left parenthesis'.  White space before or after the four characters 
appears to be immaterial, it works with or without it.


2.  Changing the operator to ' {' doesn't work, only works with 
parenthesis (not unexpected, just checking:).


3.  Space after the left parenthesis or before the right parenthesis is 
not needed.  Works with or without it.


4.  The command to the left of the operator does not need to be 
isolated.  Both:



{ read A B C D E F; }  ( echo )
and:
read A B C D E F  ( echo )

work the same.

5.  Just like '' from a file, the position of ' (...)' can be 
anywhere on the line.  This line works just like the examples above, 
though the ones used above are certainly more understandable to human eyes:


 (echo one two three four five six) read A B C D E F

--
Bob McGowan


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Probably very stupid script/bash question

2008-03-05 Thread Mark Clarkson
On Wed, 05 Mar 2008 12:16:02 -0800
Bob McGowan [EMAIL PROTECTED] wrote:

 Brian wrote:
  
  So can you explain exactly what the first  ( echo $teststring )
  does exactly please?
   
 In any case, I'd be interested in knowing where you found this
 construct.
 

The bash man page seems to be one of the few that can be read a
thousand times and /still/ find something new in it each time!

The following extract is from 'man bash' ;-) ,although what it doesn't
make clear is that (list) is preceeded by ' ', which I guess is why
it's often missed.

blockquote

   Process Substitution
   Process  substitution  is supported on systems that support
named pipes (FIFOs) or the /dev/fd method of naming open files.  It
takes the  form of  (list) or (list).  The process list is run with
its input or out- put connected to a FIFO or some file in /dev/fd.  The
name of this file is  passed  as  an argument to the current command as
the result of the expansion.  If the (list) form is used, writing to
the file will  pro- vide  input  for list.  If the (list) form is
used, the file passed as an argument should be read to obtain the
output of list.

   When available, process substitution is performed
simultaneously  with parameter  and variable expansion, command
substitution, and arithmetic expansion.

/blockquote

Cheers
Mark.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Probably very stupid script/bash question

2008-03-05 Thread Bob McGowan

Mark Clarkson wrote:

On Wed, 05 Mar 2008 12:16:02 -0800
Bob McGowan [EMAIL PROTECTED] wrote:


Brian wrote:

So can you explain exactly what the first  ( echo $teststring )
does exactly please?
 

In any case, I'd be interested in knowing where you found this
construct.



The bash man page seems to be one of the few that can be read a
thousand times and /still/ find something new in it each time!

The following extract is from 'man bash' ;-) ,although what it doesn't
make clear is that (list) is preceeded by ' ', which I guess is why
it's often missed.

blockquote

   Process Substitution
   Process  substitution  is supported on systems that support
named pipes (FIFOs) or the /dev/fd method of naming open files.  It
takes the  form of  (list) or (list).  The process list is run with
its input or out- put connected to a FIFO or some file in /dev/fd.  The
name of this file is  passed  as  an argument to the current command as
the result of the expansion.  If the (list) form is used, writing to
the file will  pro- vide  input  for list.  If the (list) form is
used, the file passed as an argument should be read to obtain the
output of list.

   When available, process substitution is performed
simultaneously  with parameter  and variable expansion, command
substitution, and arithmetic expansion.

/blockquote

Cheers
Mark.




Interesting.  But...

If I do the process substitution using a stand alone programs, it 
works as described:


$ wc (echo this is a test)
  1   4  15 /dev/fd/63

And, note the '/dev/fd' device, just as the man page describes.

If I put the above, verbatim, in a script file, it also works exactly as 
described.


It breaks when the command used is a builtin command:

$ read list (echo this is a test)
bash: read: `/dev/fd/63': not a valid identifier

In this case, I typed a CR after the first line and it hung, in fact 
it was waiting for input to the 'read' builtin.  So I typed a '^D', with 
the error message then following.


The string ' (' does not appear anywhere in the bash man page, hence 
my failure to make the association with 'process substitution'.


But, my question is still not completely answered.  What prompted Brian 
(or the original poster, if different), to add a second '' to the '('?


I suppose the next question should be what type of bug is this?  Is it a 
documentation issue, where the ' (...)' syntax simply needs explaining 
or is it a bash bug, in that a 'read list (...)' should work?


--
Bob McGowan


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Probably very stupid script/bash question

2008-03-05 Thread Mark Clarkson
On Wed, 05 Mar 2008 13:10:37 -0800
Bob McGowan [EMAIL PROTECTED] wrote:

 Mark Clarkson wrote:
  On Wed, 05 Mar 2008 12:16:02 -0800
  Bob McGowan [EMAIL PROTECTED] wrote:
  
  Brian wrote:
  So can you explain exactly what the first  ( echo
  $teststring ) does exactly please?
   
  In any case, I'd be interested in knowing where you found this
  construct.
 
  
  The bash man page seems to be one of the few that can be read a
  thousand times and /still/ find something new in it each time!
  
  The following extract is from 'man bash' ;-) ,although what it
  doesn't make clear is that (list) is preceeded by ' ', which I
  guess is why it's often missed.
  
  blockquote
  
 Process Substitution
 Process  substitution  is supported on systems that support
  named pipes (FIFOs) or the /dev/fd method of naming open files.  It
  takes the  form of  (list) or (list).  The process list is run
  with its input or out- put connected to a FIFO or some file
  in /dev/fd.  The name of this file is  passed  as  an argument to
  the current command as the result of the expansion.  If the (list)
  form is used, writing to the file will  pro- vide  input  for
  list.  If the (list) form is used, the file passed as an argument
  should be read to obtain the output of list.
  
 When available, process substitution is performed
  simultaneously  with parameter  and variable expansion, command
  substitution, and arithmetic expansion.
  
  /blockquote
  
  Cheers
  Mark.
  
  
 
 Interesting.  But...
 
 If I do the process substitution using a stand alone programs, it 
 works as described:
 
  $ wc (echo this is a test)
1   4  15 /dev/fd/63
 
 And, note the '/dev/fd' device, just as the man page describes.
 
 If I put the above, verbatim, in a script file, it also works exactly
 as described.
 
 It breaks when the command used is a builtin command:
 
  $ read list (echo this is a test)
  bash: read: `/dev/fd/63': not a valid identifier
 
 In this case, I typed a CR after the first line and it hung, in
 fact it was waiting for input to the 'read' builtin.  So I typed a
 '^D', with the error message then following.
 
 The string ' (' does not appear anywhere in the bash man page,
 hence my failure to make the association with 'process substitution'.
 
 But, my question is still not completely answered.  What prompted
 Brian (or the original poster, if different), to add a second '' to
 the '('?
 
 I suppose the next question should be what type of bug is this?  Is
 it a documentation issue, where the ' (...)' syntax simply needs
 explaining or is it a bash bug, in that a 'read list (...)' should
 work?
 

This should explain it:

$ exec 44
$ echo this is a test 4
$ wc /dev/fd/4
 1  4 15 /dev/fd/4

which of course is equivalent to

$ wc (echo this is a test)

and is not a redirection!

The man page tells me that (list) substitutes the list and it's up to
the user to choose what to do with it. I chose to redirect it, hence
the additional ' '.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Probably very stupid script/bash question

2008-03-05 Thread Bob McGowan

Mark Clarkson wrote:

On Wed, 05 Mar 2008 13:10:37 -0800
Bob McGowan [EMAIL PROTECTED] wrote:


Mark Clarkson wrote:

On Wed, 05 Mar 2008 12:16:02 -0800
Bob McGowan [EMAIL PROTECTED] wrote:


Brian wrote:

So can you explain exactly what the first  ( echo
$teststring ) does exactly please?




Deleted details available elsewhere


This should explain it:

$ exec 44
$ echo this is a test 4
$ wc /dev/fd/4
 1  4 15 /dev/fd/4

which of course is equivalent to

$ wc (echo this is a test)

and is not a redirection!

The man page tells me that (list) substitutes the list and it's up to
the user to choose what to do with it. I chose to redirect it, hence
the additional ' '.




I think I get it.  Following through with this, regarding the error seen 
with 'read' and the substitution only form:  'bash: read: `/dev/fd/4': 
not a valid identifier', I did this, based on your setup above:


$ read a b c d /dev/fd/4
1 2 3 4
bash: read: `/dev/fd/4': not a valid identifier
$ read a b c d  /dev/fd/4
$ echo  $c $d
a test

Which is just another way of illustrating that you need to redirect the 
substitution.


Thanks.

--
Bob McGowan


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Probably very stupid script/bash question

2008-03-05 Thread William Pursell

Mark Clarkson wrote:

On Wed, 05 Mar 2008 13:10:37 -0800
Bob McGowan [EMAIL PROTECTED] wrote:
If I do the process substitution using a stand alone programs, it 
works as described:


 $ wc (echo this is a test)
   1   4  15 /dev/fd/63


I couldn't find the correct place to interject this question in
the thread, so I fairly randomly selected this location...

As far as I can tell, the following 4 commands should
all behave the same, but the last one hangs.  Can anyone
see why?

$ cat (echo foo)
foo
$ bash -c 'cat (echo foo)'
foo
$ echo foo | bash -c 'cat'
foo
$ bash -c 'cat' (echo foo)


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Probably very stupid script/bash question

2008-03-05 Thread Rich Healey
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

William Pursell wrote:
 I couldn't find the correct place to interject this question in
 the thread, so I fairly randomly selected this location...
 
 As far as I can tell, the following 4 commands should
 all behave the same, but the last one hangs.  Can anyone
 see why?
 
 $ cat (echo foo)
 foo
 $ bash -c 'cat (echo foo)'
 foo
 $ echo foo | bash -c 'cat'
 foo
 $ bash -c 'cat' (echo foo)
 
 
bash is not passing it's stdin to cat's, cat is also in a subshell.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHzy8mLeTfO4yBSAcRAnU1AJwPDDxW8w6lg2uluPdPqnmHdpA2OgCgjtpM
yzemPNl95uLFTZY+XwmJxOU=
=kLad
-END PGP SIGNATURE-


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Probably very stupid script/bash question

2008-03-05 Thread Mike Bird
On Wed March 5 2008 15:36:50 William Pursell wrote:
 As far as I can tell, the following 4 commands should
 all behave the same, but the last one hangs.  Can anyone
 see why?

 $ cat (echo foo)
 foo
 $ bash -c 'cat (echo foo)'
 foo
 $ echo foo | bash -c 'cat'
 foo
 $ bash -c 'cat' (echo foo)

The last command is of the form bash -c string file.
bash file reads commands from a file, but bash -c string
reads commands from the string instead, and apparently
ignores the file argument.  The file argument is normally
omitted when -c string is used.

--Mike Bird


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Probably very stupid script/bash question

2008-03-04 Thread Brian

Georg Neis wrote:

Brian wrote:


The following does not (the value is empty):

echo $teststring | { read A B C D E F; }
echo Data received = $E Bytes  --- $E is empty

I assume it has something to do with the read command being executed in
a subshell.


Yes.


So how can I extract the parts I want into variables to use them later
on in the script?


$ teststring='field1 field2 field3'
$ set -- $teststring
$ echo $2
field2

Regards,
Georg



Georg,

this works perfectly thanks.

Cheers Brian


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Probably very stupid script/bash question

2008-03-04 Thread Brian

Mark Clarkson wrote:

On Mon, 2008-03-03 at 19:48 +0100, Brian wrote:

echo $teststring | { read A B C D E F; }
echo Data received = $E Bytes  --- $E is empty


{ read A B C D E F; }  ( echo $teststring )
echo Data received = $E Bytes  --- $E is empty



Robomod,

I could not get this to work, the shell complains:

./dirvish-mail.sh: 98: Syntax error: redirection unexpected

The other solution from Alex:

 echo $teststring | ( read A B C D E F; )

did not work either.

Then I got to wondering about why a few methods that I had tried before 
posting did not work either, although they were documented many times. I 
was doing the testing on an NSLU2 which uses Busybox, and its default 
shell sh and not bash (I also have an NSLU2 with Debian on it, there 
the shell is bash). So I assume this has something to do with busybox's 
shell.


Of course, both solutions work perfectly under bash.

Cheers Brian


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Probably very stupid script/bash question

2008-03-04 Thread Mark Clarkson
On Tue, 04 Mar 2008 18:46:05 +0100
Brian [EMAIL PROTECTED] wrote:

 
 I could not get this to work, the shell complains:
 
 ./dirvish-mail.sh: 98: Syntax error: redirection unexpected
 

Interesting to note that this does not work under busybox. I think
this is rather an esoteric but often useful bash feature. (It also
needs /proc so is not available in some special cases.)

 The other solution from Alex:
 
   echo $teststring | ( read A B C D E F; )
 
 Of course, both solutions work perfectly under bash.
 

This should not have worked under bash either since it is still running
in a sub-shell, so the variables are lost when read finishes.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Probably very stupid script/bash question

2008-03-03 Thread Brian

Hi,

I tried using bash to split a string. This works OK:

echo $teststring | { read A B C D E F;  echo Data received = $E Bytes; }

The following does not (the value is empty):

echo $teststring | { read A B C D E F; }
echo Data received = $E Bytes  --- $E is empty

I assume it has something to do with the read command being executed in 
a subshell.


So how can I extract the parts I want into variables to use them later 
on in the script?


Thanks in advance

Cheers Brian


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: Probably very stupid script/bash question

2008-03-03 Thread Alex Samad
On Mon, Mar 03, 2008 at 07:48:49PM +0100, Brian wrote:
 Hi,

 I tried using bash to split a string. This works OK:

 echo $teststring | { read A B C D E F;  echo Data received = $E Bytes; }

 The following does not (the value is empty):

 echo $teststring | { read A B C D E F; }
 echo Data received = $E Bytes  --- $E is empty
maybe 

echo $teststring | ( read A B C D E F; )

why do you need the {} or ()


 I assume it has something to do with the read command being executed in  
 a subshell.

 So how can I extract the parts I want into variables to use them later  
 on in the script?

 Thanks in advance

 Cheers Brian


 -- 
 To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a 
 subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



-- 
I hear the voices, and I read the front page, and I know the speculation, but 
I’m the decider and I decide what is best. And what’s best is for Don Rumsfeld 
to remain as secretary of defense.

- George W. Bush
04/18/2006
Washington, DC


signature.asc
Description: Digital signature


Re: Probably very stupid script/bash question

2008-03-03 Thread Mark Clarkson
On Mon, 2008-03-03 at 19:48 +0100, Brian wrote:
 echo $teststring | { read A B C D E F; }
 echo Data received = $E Bytes  --- $E is empty

{ read A B C D E F; }  ( echo $teststring )
echo Data received = $E Bytes  --- $E is empty


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Probably very stupid script/bash question

2008-03-03 Thread Georg Neis
Brian wrote:

 The following does not (the value is empty):
 
 echo $teststring | { read A B C D E F; }
 echo Data received = $E Bytes  --- $E is empty
 
 I assume it has something to do with the read command being executed in
 a subshell.

Yes.

 So how can I extract the parts I want into variables to use them later
 on in the script?

$ teststring='field1 field2 field3'
$ set -- $teststring
$ echo $2
field2

Regards,
Georg


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]