Sorry - in the old days Reply To: was list.
Forwarded Message
Subject: Re: [Dorset] Multiple commands in bash
Date: Thu, 12 Mar 2015 15:10:30 +
From: TimA t...@ls83.eclipse.co.uk
To: Andrew Montgomery-Hurrell darkliq...@darkliquid.co.uk
Hi Andrew
That achieves the same as
#!/bin/bash -v
echo 1
echo 2
echo 3
I don't particularly need to place the commands in an array. I need to
avoid any faking too.
I'm thinking perhaps spawning bash from an expect script is the way to
do this.
Cheers
Tim
On 12/03/15 14:42, Andrew Montgomery-Hurrell wrote:
Not sure if this is what you want, but something like the following might
work. It doesn't do the bash prompt since there is not way of getting the
current prompt output reliably, but if you just want a fake one for display
purposes, you could hard code it into the script. Also, it doesn't check
the exit codes and abort early, as the would do, but that's easy enough
to add in.
#!/bin/bash
COMMANDS=()
COMMANDS[0]=echo 1
COMMANDS[1]=echo 2
COMMANDS[2]=echo 3
for ((i = 0; i ${#COMMANDS[@]}; i++)) ; do
echo ${COMMANDS[$i]}
${COMMANDS[$i]}
done
On Thu, 12 Mar 2015 at 14:13 TimA t...@ls83.eclipse.co.uk wrote:
Hi
I'd like to run multiple commands in Bash:
patch -m patchfile hg diff cd dir make -s
but for audit purposes I'd like each command in the list to be echoed as
run, even better I'd like the Bash prompt to appear too in front of each
line.
I know that as an alternative I can put the commands in a script with
#!/bin/bash -v to get the first requirement.
Cheers
Tim
--
Next meeting: Bournemouth, Tuesday, 2015-04-07 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
--
Next meeting: Bournemouth, Tuesday, 2015-04-07 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
--
Next meeting: Bournemouth, Tuesday, 2015-04-07 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR