Re: Bash Scripting Question

2013-11-07 Thread Chris Davies
Jonathan Dowland wrote: > On Sun, Nov 03, 2013 at 09:58:58PM +0100, Erwan David wrote: >> Maybe you'll need something like expect to handle this. > I'd second expect, it's probably the best tool for the job in all > non-trivial cases. The "empty-expect" package, perhaps? Chris -- To UNSUBSCRI

Re: Bash Scripting Question

2013-11-05 Thread Zenaan Harkness
On 11/4/13, Thomas H. George wrote: > The script I am trying to write executes a program that requires a > keyboard response. I have experimented with redirecting STDIN but haven't > found the > correct way to make the response. To read a value (perhaps half your "problem"): apt-cache show ... z

Re: Bash Scripting Question

2013-11-04 Thread Karl E. Jorgensen
Hi On Sun, Nov 03, 2013 at 02:35:30PM -0500, Thomas H. George wrote: > The script I am trying to write executes a program that requires a > keyboard response. I have experimented with redirecting STDIN but haven't > found the > correct way to make the response. I found one example that scanned t

Re: Bash Scripting Question

2013-11-04 Thread Jonathan Dowland
The tool 'yes' can be used to write an infinite stream of strings (the default being 'y') to standard output, so if your program needed only a sequence of a fixed string such as 'y', you could do > yes | your-program or > yes "some-other-string" | your-program But if your program is not readin

Re: Bash Scripting Question

2013-11-03 Thread Erwan David
Le 03/11/2013 20:35, Thomas H. George a écrit : > The script I am trying to write executes a program that requires a > keyboard response. I have experimented with redirecting STDIN but haven't > found the > correct way to make the response. I found one example that scanned the > response from apt

Re: Bash Scripting Question

2013-11-03 Thread Cousin Stanley
> The script I am trying to write executes a program > that requires a keyboard response. > A varaible can be set to a keyboard response using a read prompt read -e -p "What do you need ?" xVariable echo $xVariable -- Stanley C. Kitching Human Being Phoenix, Arizon

Re: bash scripting question

2010-03-29 Thread Karl Vogel
Here's something I modified as part of a benchmark script called "fdtree". -- Karl Vogel I don't speak for the USAF or my company Dijkstra probably hates me. --Linus Torvalds, in kernel/sched.c #!/bin/bash # How to use xdate/xtime/persec: # # START=$(date "+%s")

Re: bash scripting question

2010-03-29 Thread Ron Johnson
On 2010-03-29 16:35, Mike McClain wrote: [snip] Thanks a lot. Though my error was pointed out as a typo and corrected a while back your solution using " date '+%s' " is much more elegant than what I had done. If you want more (possibly too much) precision: $ date +'%s.%N' -- "History does not

Re: bash scripting question

2010-03-29 Thread Mike McClain
Hi Josep, On Mon, Mar 29, 2010 at 02:28:20PM +0200, Josep M. wrote: > > I found these somewhere time ago. check if is what You need: > Thanks a lot. Though my error was pointed out as a typo and corrected a while back your solution using " date '+%s' " is much more elegant than what I had don

Re: bash scripting question

2010-03-29 Thread Josep M.
Hello. I found these somewhere time ago. check if is what You need: function timer() { if [[ $# -eq 0 ]]; then echo $(date '+%s') else local stime=$1 etime=$(date '+%s') if [[ -z "$stime" ]]; then stime=$etime; fi dt=$((etime - stime)

Re: bash scripting question

2010-03-19 Thread Chris Jackson
Paul E Condon wrote: Try: bgn=$(date +%s) sleep 7 end=$(date +%s) echo "elapsed seconds = " $(( end - bgn )) You might also want to experiment with: ps h -o etime $$ as long as you're happy with it only running under gnu. Prints the elapsed time for the shell. -- Chris Jackson Shadowcat

Re: bash scripting question

2010-03-19 Thread Paul E Condon
On 20100319_101928, Mike McClain wrote: > I've written a function to print elapsed time similar to /usr/bin/time > but can be called at the beginning and end of a script from within > the script. Occasionally I get an error: '8-08: value too great for base' > It's caused by the difference in these

Re: bash scripting question

2010-03-19 Thread Mike McClain
On Fri, Mar 19, 2010 at 06:45:15PM +0100, Sven Joachim wrote: > On 2010-03-19 18:19 +0100, Mike McClain wrote: > > > I've written a function to print elapsed time similar to /usr/bin/time > > but can be called at the beginning and end of a script from within > > the script. Occasionally I get an e

Re: bash scripting question

2010-03-19 Thread Mike McClain
On Fri, Mar 19, 2010 at 10:19:28AM -0700, Mike McClain wrote: typo right herevv > now='09:07:16'; startHr=${now%%:*}; startHR=${startHr#*0}; echo $startHr; Apologies for troubling all. Mike (with egg on face) -- Satisfied user of Linux since 1997. O< ascii ribbon c

Re: bash scripting question

2010-03-19 Thread Wayne
Mike McClain wrote: I've written a function to print elapsed time similar to /usr/bin/time but can be called at the beginning and end of a script from within the script. Occasionally I get an error: '8-08: value too great for base' It's caused by the difference in these 2 command strings but I ca

Re: bash scripting question

2010-03-19 Thread Chris Jackson
Mike McClain wrote: I've written a function to print elapsed time similar to /usr/bin/time but can be called at the beginning and end of a script from within the script. Occasionally I get an error: '8-08: value too great for base' It's caused by the difference in these 2 command strings but I c

Re: bash scripting question

2010-03-19 Thread S Scharf
On Fri, Mar 19, 2010 at 1:19 PM, Mike McClain wrote: > I've written a function to print elapsed time similar to /usr/bin/time > but can be called at the beginning and end of a script from within > the script. Occasionally I get an error: '8-08: value too great for base' > It's caused by the diffe

Re: bash scripting question

2010-03-19 Thread Sven Joachim
On 2010-03-19 18:19 +0100, Mike McClain wrote: > I've written a function to print elapsed time similar to /usr/bin/time > but can be called at the beginning and end of a script from within > the script. Occasionally I get an error: '8-08: value too great for base' > It's caused by the difference i

Re: bash scripting question

2007-05-17 Thread Bob McGowan
Tyler Smith wrote: On 2007-05-17, Bob McGowan <[EMAIL PROTECTED]> wrote: Some general comments, mostly aimed at making your code cleaner without changing what it does. First, both 'echo' and 'printf' put their results on standard out. Your call of 'printf' is inside command substitution, so

Re: bash scripting question

2007-05-16 Thread Alex Samad
On Thu, May 17, 2007 at 03:40:15AM +, Tyler Smith wrote: > On 2007-05-17, Bob McGowan <[EMAIL PROTECTED]> wrote: > > > > Some general comments, mostly aimed at making your code cleaner without > > changing what it does. > > > > First, both 'echo' and 'printf' put their results on standard out.

Re: bash scripting question

2007-05-16 Thread Tyler Smith
On 2007-05-17, Bob McGowan <[EMAIL PROTECTED]> wrote: > > Some general comments, mostly aimed at making your code cleaner without > changing what it does. > > First, both 'echo' and 'printf' put their results on standard out. Your > call of 'printf' is inside command substitution, so its STDOUT

Re: bash scripting question

2007-05-16 Thread Bob McGowan
Tyler Smith wrote: Hi, I've got a question about a short bash script I wrote. I need it to --snipped-- #!/bin/bash lab_num=41 for map_name in aest_90 bush_90 carol_90 comp_90 \ hirs_90 roan_90 swan_90 vir_90 ; do lab_let=$(echo -n $(printf "\\x$(echo $lab_num)")) echo " $la

Re: bash scripting question

2007-05-16 Thread Tyler Smith
On 2007-05-16, Karl E. Jorgensen <[EMAIL PROTECTED]> wrote: >> This was the only way I could figure out to loop from A to H. But >> since it works on hex escape codes, it won't work past 9. Is there a >> cleaner, more general way to do this? > > I think there is: > > #!/bin/bash > > ( cat < A aest_

Re: bash scripting question

2007-05-16 Thread Karl E. Jorgensen
On Wed, May 16, 2007 at 08:46:37PM +, Tyler Smith wrote: > Hi, > > I've got a question about a short bash script I wrote. I need it to > loop over a number of names, and pass a command to grass that includes > two variations of those names. That was easy. Harder was getting > getting a letter

Re: BASH Scripting Question

2005-11-25 Thread David Kirchner
On 11/25/05, Metrics <[EMAIL PROTECTED]> wrote: > Hi all, > > Can someone explain to me the following behaviour? I have this script > > #!/bin/sh > > LISTS=('debian-user' 'security-basics' 'hostap' 'pen-test' 'ntbugtraq' > 'ion-general' 'vim' 'madwifi'); > LIST_COUNT=${#LISTS} > echo $LIST_COUNT >

Re: bash scripting question

2002-11-03 Thread Joshua Lee
On Sun, Nov 03, 2002 at 12:28:26PM -0700, Bob Proulx wrote: > get around 40,000 files in one single directory. Some filesystems > such as JFS (and I think, not sure, XFS and ReiserFS too) store > directies in B+ trees and are specifically designed to handle large I know that ReiserFS does this. X

Re: bash scripting question

2002-11-03 Thread Bob Proulx
Neal Lippman <[EMAIL PROTECTED]> [2002-11-03 13:35:22 -0500]: > Thanks. My "bug" here was using comma instead of space as the separator, > and not realizing that the reason for x in {a,b,c,d...z} worked was > because of the way the brace expansion was being done by the shell. Ah, yes, csh style {o

Re: bash scripting question

2002-11-03 Thread Jesus Climent
On Sat, Nov 02, 2002 at 10:51:00PM -0500, Neal Lippman wrote: > > This works fine if I actually type out the entire alphabet list on the > command line as above, but that's sort of a pain. So, I tried setting a > shell variable to the alphabet string (export alpha="A,B,C,...,Z"), but > then the co

Re: bash scripting question

2002-11-03 Thread Bob Proulx
Neal Lippman <[EMAIL PROTECTED]> [2002-11-02 22:51:00 -0500]: > I am trying to solve a bash scripting problem, but I cannot figure it > out. > > I frequently need to execute a command of the form: > for x in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z); do >;

Re: bash scripting question

2002-11-03 Thread Bob Proulx
[EMAIL PROTECTED] <[EMAIL PROTECTED]> [2002-11-03 18:15:06 +0200]: > On Sat, Nov 02, 2002 at 10:05:45PM -0600, Michael Heironimus wrote: > > alpha="a b c d e z" > > for x in $alpha ; do > > echo $x > > done > > > > I think this should work in any Bourne-style shell > > Doesn't wo

Re: bash scripting question

2002-11-03 Thread Bob Proulx
Matthias Hentges <[EMAIL PROTECTED]> [2002-11-03 18:32:29 +0100]: > Am Son, 2002-11-03 um 04.51 schrieb Neal Lippman: > > I frequently need to execute a command of the form: > > for x in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z); do > Your problem ist the wrong setting of th

Re: bash scripting question

2002-11-03 Thread Matthias Hentges
Am Son, 2002-11-03 um 04.51 schrieb Neal Lippman: > I am trying to solve a bash scripting problem, but I cannot figure it > out. > > I frequently need to execute a command of the form: > for x in {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z); do >; > don

Re: bash scripting question

2002-11-03 Thread shaulka
On Sat, Nov 02, 2002 at 10:05:45PM -0600, Michael Heironimus wrote: > On Sat, Nov 02, 2002 at 10:51:00PM -0500, Neal Lippman wrote: > > shell variable to the alphabet string (export alpha="A,B,C,...,Z"), but > > then the command: > > for x in {$alpha} ; > > do > > echo $x; > >

Re: bash scripting question

2002-11-02 Thread Michael Heironimus
On Sat, Nov 02, 2002 at 10:51:00PM -0500, Neal Lippman wrote: > shell variable to the alphabet string (export alpha="A,B,C,...,Z"), but > then the command: > for x in {$alpha} ; > do > echo $x; > done > winds up printing the string "{A,B,C,...,Z}" rather than each l

Thank you all! (Was: Re: bash scripting question (variables and spaces))

2002-03-20 Thread Karsten Heymann
Thank you all! Now it works. * Gustavo Noronha Silva <[EMAIL PROTECTED]> [020320 09:25]: ... > C="$A $B" -- Karsten Heymann <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> CAU-University Kiel, Germany Registered Linux User #221014 (http://counter.li.org)

Re: bash scripting question (variables and spaces)

2002-03-19 Thread Brett Parker
On Tue, Mar 19, 2002 at 08:35:53PM +0100, Karsten Heymann wrote: > Hi, > > I have once again come upon bash problem I can't solve. I'm writing a > little bash frontend and one of the programs expects a option that includes > spaces and is composed from two other shell var's. Example: > > #!/bin/b

Re: bash scripting question (variables and spaces)

2002-03-19 Thread Angus D Madden
Karsten Heymann, Tue, Mar 19, 2002 at 08:35:53PM +0100: > Hi, > > I have once again come upon bash problem I can't solve. I'm writing a > little bash frontend and one of the programs expects a option that includes > spaces and is composed from two other shell var's. Example: > > #!/bin/bash > A=

Re: bash scripting question (variables and spaces)

2002-03-19 Thread Gustavo Noronha Silva
On Tue, 19 Mar 2002 20:35:53 +0100 Karsten Heymann <[EMAIL PROTECTED]> wrote: > Hi, > > I have once again come upon bash problem I can't solve. I'm writing a > little bash frontend and one of the programs expects a option that includes > spaces and is composed from two other shell var's. Example:

Re: bash scripting question (variables and spaces)

2002-03-19 Thread David Z Maze
Karsten Heymann <[EMAIL PROTECTED]> writes: > Hi, > > I have once again come upon bash problem I can't solve. I'm writing > a little bash frontend and one of the programs expects a option that > includes spaces and is composed from two other shell var's. Example: > > #!/bin/bash > A="Hello" > B="

Re: bash scripting question (variables and spaces)

2002-03-19 Thread Paul F. Pearson
On Tue, 19 Mar 2002, Karsten Heymann wrote: > Hi, > > I have once again come upon bash problem I can't solve. I'm writing a > little bash frontend and one of the programs expects a option that includes > spaces and is composed from two other shell var's. Example: > > #!/bin/bash > A="Hello" > B=

Re: bash scripting question (variables and spaces)

2002-03-19 Thread J.H.M. Dassen \(Ray\)
On Tue, Mar 19, 2002 at 20:35:53 +0100, Karsten Heymann wrote: > A="Hello" > B="Karsten" > C=$A $B > someprog --greeting $C Variable expansion happens first: someprog --greeting Hello Karsten then tokenising, so someprog get three arguments: 1. --greeting 2. Hello

Re: bash scripting question (variables and spaces)

2002-03-19 Thread ktb
On Tue, Mar 19, 2002 at 08:35:53PM +0100, Karsten Heymann wrote: > Hi, > > I have once again come upon bash problem I can't solve. I'm writing a > little bash frontend and one of the programs expects a option that includes > spaces and is composed from two other shell var's. Example: > > #!/bin/b

Re: bash scripting question (variables and spaces)

2002-03-19 Thread Craig Dickson
This should work, though I have not actually tried it: #!/bin/bash A="Hello" B="Karsten" C="$A $B" someprog --greeting "$C" pgpiX8Z2JqpWm.pgp Description: PGP signature