Re: Bash Scripting Question

2013-11-07 Thread Chris Davies
Jonathan Dowland j...@debian.org 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

Re: Bash Scripting Question

2013-11-05 Thread Zenaan Harkness
On 11/4/13, Thomas H. George li...@tomgeorge.info 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):

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 reading

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 the

Bash Scripting Question

2013-11-03 Thread Thomas H. George
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-get install for the letter y and fed this back to

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, Arizona

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-get

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-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: 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

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 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) #

bash scripting question

2010-03-19 Thread Mike McClain
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 can't for the life of

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 in

Re: bash scripting question

2010-03-19 Thread S Scharf
On Fri, Mar 19, 2010 at 1:19 PM, Mike McClain mike.j...@nethere.com 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

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

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

Re: bash scripting question

2010-03-19 Thread Mike McClain
On Fri, Mar 19, 2010 at 10:19:28AM -0700, Mike McClain wrote: snip 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

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 error:

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 2

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

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

bash scripting question

2007-05-16 Thread Tyler Smith
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 included in each iteration, starting with A for the first one and going

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

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_90 B

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

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 becomes

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. Your

BASH Scripting Question

2005-11-25 Thread Metrics
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 for ((i=0;i$LIST_COUNT-1;i++)); do echo

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 for

Re: OT: bash scripting question -- passing values to ls

2004-01-06 Thread David Z Maze
Matt Price [EMAIL PROTECTED] writes: here's something that ocmes up a lot for me: I use locate to find a bunch of files: % locate charter | grep -i font /usr/share/texmf/fonts/afm/bitstrea/charter /usr/share/texmf/fonts/tfm/bitstrea/charter /usr/share/texmf/fonts/type1/bitstrea/charter

OT: bash scripting question -- passing values to ls

2004-01-04 Thread Matt Price
hey folks, here's something that ocmes up a lot for me: I use locate to find a bunch of files: % locate charter | grep -i font /usr/share/texmf/fonts/afm/bitstrea/charter /usr/share/texmf/fonts/tfm/bitstrea/charter /usr/share/texmf/fonts/type1/bitstrea/charter

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Nano Nano
On Sun, Jan 04, 2004 at 02:27:11AM -0500, Matt Price wrote: so I have to do it by hand at the moment. But shouldn't I be able to automate it with somthing like: ls locate charter | grep -i font ? nothing I try works -- but I can't believe it's impossible! any hints? I use backticks:

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Kevin Mark
On Sun, Jan 04, 2004 at 02:27:11AM -0500, Matt Price wrote: hey folks, here's something that ocmes up a lot for me: I use locate to find a bunch of files: % locate charter | grep -i font /usr/share/texmf/fonts/afm/bitstrea/charter /usr/share/texmf/fonts/tfm/bitstrea/charter

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Nano Nano
On Sun, Jan 04, 2004 at 03:36:36AM -0500, Kevin Mark wrote: [snip] locate charter| grep -i font | while read line; do ls -l $line; done Invoking 'ls' in a loop is semantically different from invoking it once, although you can compensate for it. I prefer backticks because you can

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Nano Nano
On Sun, Jan 04, 2004 at 01:10:51AM -0800, Nano Nano wrote: [snip] it looks messier) and you can't use the sort options of less, for i meant sort options of ls -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Colin Watson
On Sun, Jan 04, 2004 at 03:36:36AM -0500, Kevin Mark wrote: I use a little bash code over and over again. Its a while loop. locate charter| grep -i font | while read line; do ls -l $line; done It has many uses and it doesnt have a limit like xargs. I found out about xargs but

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Paul Morgan
On Sat, 03 Jan 2004 23:34:59 -0800, Nano Nano wrote: On Sun, Jan 04, 2004 at 02:27:11AM -0500, Matt Price wrote: so I have to do it by hand at the moment. But shouldn't I be able to automate it with somthing like: ls locate charter | grep -i font ? nothing I try works -- but I can't

Re: OT: bash scripting question -- passing values to ls

2004-01-04 Thread Gregory Seidman
On Sun, Jan 04, 2004 at 02:27:11AM -0500, Matt Price wrote: [...] } ls locate charter | grep -i font } ? } nothing I try works -- but I can't believe it's impossible! any } hints? locate charter | grep -i font | tr '\012' '\000' | xargs -0 ls -ld xargs is your friend. So is tr. Learn them

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; done

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 do something with

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 work for me in bash:

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 do

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 command:

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

bash scripting question

2002-11-02 Thread 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 do something with each x ; done This works fine if I actually

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 letter on

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)

bash scripting question (variables and spaces)

2002-03-19 Thread Karsten Heymann
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=Karsten C=$A $B someprog --greeting $C Whatever I do now,

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

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/bash

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 3.

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=Karsten

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=Karsten C=$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 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=Hello

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/bash