How to Force command substitution evaluation in bash?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Force command substitution evaluation in bash?
# 15  
Old 04-15-2016
Hi siegfried,
In post #2 in this thread, I said:
Quote:
Show us the source for your BackupRecords program.
In post #4 in this thread I said:
Quote:
The only thing that makes sense to me is that value returned by BackupRecords --log must return a string that includes a command substitution (from the description, probably including an invocation of the date utility) that produces different results each time $BUPLOG is expanded. But, the only way to know for sure is to see the source for BackupRecords.
In post #6 in this thread, shamrock said:
Quote:
I agree with the others in that the answer lies somewhere in your BackupRecords script...
In post #8 in this thread, I said:
Quote:
If you won't show us the code for BackupRecords, it is REALLY REALLY hard for us to tell you how to fix it to do what you want.
Instead of showing us the source for your BackupRecords program as we have requested four times, you keep asking us to tell you how to fix code that you will not let us see,.

We want to help you. PLEASE HELP US HELP YOU! Please show us the source for BackupRecords! If you won't show us the source for BackupRecords, we are all wasting our time trying to help you. PLEASE HELP US HELP YOU! Show us the source for BackupRecords!
# 16  
Old 04-16-2016
I apologize for not being more response. I've been working a lot of overtime and I did not have time to post an abbreviated version of BackupRecords.

I also apologize for not writing this little test program before posting.
This works fine.

Code:
export BUPLOG="`Date "+%Y-%b-%d-%H-%M-%S"`"
echo $BUPLOG
sleep 60
echo $BUPLOG
export BUPLOG="`Date "+%Y-%b-%d-%H-%M-%S"`"
echo $BUPLOG

This produces the desired results:
Code:
./logdemo.sh
2016-Apr-15-21-53-34
2016-Apr-15-21-53-34
2016-Apr-15-21-54-34

I thought surely bash was to blame for my multiple log files but apparently not! Bash is working exactly as I need it to...

And it actually turns out that sometimes I'm not getting multiple log files. So now I need to figure out why.

Thanks for all your help.
Siegfried
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Evaluation of test command

Could somebody please explain to me why and how the highlighted line(s) (?) of code puts the "test" evaluation into "result" and then to $enable_static ? Or does not ? I did comment out the original code and changed it to what I feel is less cryptic , but the "result" is still wrong =... (3 Replies)
Discussion started by: anne
3 Replies

2. Shell Programming and Scripting

How to Force command substitution evaluation in bash?

OK, I'm striving to abide by all the rules this time. Here is a fragment of my windows10/cygwin64/bash script: export BUPLOG=$(BackupRecords --log "$src") robocopy $(BackupRecords -mrbd "$src" --path "$src") $(BackupRecords --appSwitches "$src") "$src" "$dst" $(BackupRecords --fileSwitches... (0 Replies)
Discussion started by: siegfried
0 Replies

3. Shell Programming and Scripting

Bash regex evaluation not workin

I'm building a script that may received start and end date as parameters. I whant to make it as flexible as possible so I'm accepting epoch and date in a way that "date --date=" command may accept. In order to know if parameter provided is an epoc or a "date --date=" string I evaluate if the value... (2 Replies)
Discussion started by: lramirev
2 Replies

4. Shell Programming and Scripting

bash, command line substitution

I have one script calling another with a set of strings that includes white space. Script A calls Script B with these input strings: one two "th ree" Script B pulls apart the arguments correctly: arg0 = one, arg1 = two, arg2 = "th ree" if I call it from within Script A like so:... (10 Replies)
Discussion started by: skippyV
10 Replies

5. UNIX for Dummies Questions & Answers

cp command evaluation

Hi all! I'm writting one script to copy a file in various folders, but there are 2 things to validate. First that the folder where i'll be cpying exists, and second that i have permissions to copy the file in it. so far i have found the way to validate the folder exists, but when trying to... (6 Replies)
Discussion started by: feliperivera
6 Replies

6. Shell Programming and Scripting

Correct bash substitution

Hello! I'm writing a shell script using #!/bin/bash instead of #!/bin/sh because of the substitution: ${!variable}, which won't work with sh. My main problem is the following (just a summarized example, the script is much more complex): # sourced from a configuration file, we have a lot of... (6 Replies)
Discussion started by: teresaejunior
6 Replies

7. Shell Programming and Scripting

[bash] command line substitution with environmental variables

Hi, I'm using an array that contains compiler FLAGS that need to be executed either before ./configure or after the main 'make' command. example of array containing compiler flags. ------------------------------------------------- FLAGS="CFLAGS=\"-arch x86_64 -g -Os -pipe... (7 Replies)
Discussion started by: ASGR
7 Replies

8. Shell Programming and Scripting

/bin/bash - variable substitution.

Is it possible with a bash variable to perform multiple substitution strings to one variable? I have this variable: echo $clock TIMEZONE="US/Central" What I would like to do with bash only it pull out just the "US" part of the variable.. which could be any number of countries. this is... (6 Replies)
Discussion started by: trey85stang
6 Replies

9. Shell Programming and Scripting

How do I perform double substitution in bash?

#!/bin/bash #set -x MAX=255 FILE=$1.dns_list #declare -a d_arr if then echo "Usage: `basename $0` network" echo " e.g.`basename $0` 1.1.1" exit fi echo "Remove file $FILE..." rm $FILE for (( i = 1; i < $MAX; i++ )) do PARSE=$(host $1.${i}) ... (3 Replies)
Discussion started by: flee
3 Replies
Login or Register to Ask a Question