BASH Script - What am I doing wrong in this test? - BASH Script
example page I had to go and check it to make sure it was not a me mistake.
http://tldp.org/LDP/Bash-Beginners-G...ect_07_01.html Code:
if [ -f /var/log/messages ] just check to see if file is present if true returns 0 then acts on it. my code. Code:
script_dir="~/scripts" Code:
[[ -f "${script_dir}"/"${NewFile}" ]] && resampledFileLoc="${script_dir}"/"${NewFile}" Code:
next line is to lame flac file Code:
Code:
entire partial code block ( did you see what I did? I said entire partial code block that contradicts itself ;) you didn't catch that did you? ) Code:
|
Please create a complete script that shows the problem and is minimal (everything in it is essential to produce the problem),
|
Quote:
Code:
|
Are you sure that every line of this scripts is necessary to show the problem?
|
yes because of this ;;;;;
if you change it to suit your system then run it, using test data one flac and one mp3 you'll see that none of the variables are being set or loses its value when a test returns true. but look at it. Code:
+ ALBUM='Marquee Moon ' Code:
/media/data/Sorted_iPhone-Music/Television/Marquee Moon |
I have not been able to make sense of the original question or the following test case.
Please show us this and exactly this so that we can understand it and repeat it... * Some variable with a value, echo that value * Your test of that variable from your code which you say is affecting the variable value * That same variable value after the test at which point you say has lost its value |
Code:
script_dir="~/scripts" |
Quote:
broke down as this is doing this with every test then set the value then it is lost through out the entire script. without set -x using printf - results are this Code:
Code:
f=$FILENAME set -x out put nd what I got a look at to show me that it is not working. Code:
I do not know what else I can show you that is not already there I can decipher it lets me see if I can break it down some more... the whole script is doing this. Code:
Code:
Encoding <stdin> to 01 - Albatross.mp3 Code:
#!/bin/bash |
Quote:
Code:
this back Code:
working_dir="/home/userx/Music" better yet Code:
script_dir="/home/userx/resort-resamplemp3a" |
Just using the Meta Tags example
here we see that YES in fact the value is gotten off the file Code:
I test to be sure that their is a value within the ARTIST and ALBUM first because I already know their is a value in copy_to Code:
copy_to="/media/data/Sorted_iPhone-Music" then what is inside of $artist is immediately lost afterwords. we see that here. Code:
Code:
printf "\n artist 1 --> $artist\n\n" |
THIS WORKS! no variable values are being lost at all..
MIND you this is a completely different script but the same logic and data extraction and test are being used I dug this one out of all of the old scripts I have, I thought I'd lost it --- but still Code:
#!/bin/bash Code:
but that other one where I combined mp3 and flac which I have done countless times to be processed at the same time is not working properly WHY? |
Does not work as for me either. Try removing the parenthesis.
Code:
[[ -n "${ARTIST}" ]] && artist="$copy_to"/"$ARTIST" ; mkdir -pv "${artist}" |
... none of which answered my request...
The point of troubleshooting is to isolate the point at which some unexpected behavior occurs, and identify the specific cause. The point of asking for an exact, simplest case is to help you isolate both what is happening and where it is happening. In the process of attempting to provide those answers you will either provide us the information we need to understand the problem, or often as not, you will find that the problem is not what you thought it was... either way it is progress! Not attempting to answer those questions as asked leaves us several lengthy posts later, no closer to understanding the actual problem. Changing to another script entirely is also not helpful as the proverbial wild geese typically enter at that point... The debugging output produced by set -xv is mostly helpful to the person sitting at the keyboard. It is a powerful option to help you interactively isolate and identify what your code is actually doing at runtime. We cannot participate in that interactive debugging process, so posting the debugging output is less helpful to us. What is helpful to us is attempting to provide the results of your own interactive use of that debugging output, the isolated errant code. You have posited that some variable was losing its value after some test. Repeatedly justifying that conclusion with lengthy debugging output is not helpful. Attempting to isolate the point at which the variable loses its value, as reqquested would be helpful to us and to you. You will often see people here ask, "Help us help you". This is one of those times. |
OK RESET EVERY THING I rewrote the entire script and am still getting the same problem.
let me see which first, script or results? script is this Bold shows code to print value in variable Code:
#!/bin/bash Code:
userx@slackwhere⚡~/scripts $./resample-flacy now what are your thoughts on this? sorry but I felt if a rewrite was done it might just work. and be less confusing to read. so I condensed everything for you ;) looks nice huh? :D |
I did a reassment on that var and reset it to the proper vaule but am still getting
Code:
+ mv -v '/home/userx/scripts/02 - Memories.mp3' '/media/data/Sorted_iPhone-Music/Public Image Ltd./Metal Box' ' ' Code:
the reassignment btw Code:
|
All times are GMT -5. The time now is 11:25 PM. |