strange behavior in a bash script
hi there, i am having weird issues here.
my script goes sth like this: script1.sh #!/bin/bash source ./script2.sh my folder structure looks like this: folder1/script1.sh /script2.sh i am executing like this: Code:
$./script1.sh script1.sh: line x: script2.sh: No such file or directory the problem is not the script or syntax, because if i create a new file in folder1, say script1-1.sh, and copy paste the content of script1.sh to it, it executes just fine. i suspect bash or my shell emulator to be the culprit here. while writing this i just realized that my problem is easily solved with a copy paste, but i'd rather want to know what is going on here and fix it. my terminal is xfce4-terminal 0.6.3, bash version is 4.3.11(1) on linux mint xfce x86, the system is practically fresh save for some changes in the firefox configuration and changing the opacity of said shell emulator. the system is up for some time now, though, about a week with some supends in between. any help or pointers appreciated, thanks a lot! EDIT: btw, since the system is practically fresh not much was done or saved on it, if someone is curious she or he could have a look at it through teamwiewer or ssh or whatever, i am not that much of an expert there. |
Are you in folder1 when you run this script? Or is folder1 in your PATH variable?
The directory where script2.sh is located is important. Remember that ./script2.sh means to run that from the current working directory. Therefore if you are not in the directory where script2.sh is located, you will see exactly the complaint you are seeing. Another thing to consider is to add Code:
set -xv Please remember to use [code][/code] tags to enclose your code. |
Quote:
If they're in the same directory, why are you even qualifying the directory to script2? Code:
source script2.sh |
still not working
first of all, thanks for your reply.
i made sure my cwd is set correctly, which it was, and also activated the debugging options. unfortunately no luck with that. these only give me two additional lines after i execute Code:
./script1.sh just for the hell of it i added Code:
echo hello Code:
source ./script2.sh |
Quote:
Code:
source script2.sh I'm wondering if there is something in script2 itself causing this. Of course, I'm thinking we're not seeing the actual scripts, and so we can't fully diagnose the problem. |
some other tries
yeah, lq seems to have lost the formatting there. structure should be like this
Code:
folder1/script1.sh but as i posted before, that is not the problem at all. the script is simply not executed as it is, bash is executing an old version of it. i closed the shell and opened another one, same error. i typed Code:
bash any other terminals i could try on linux mint? |
ok, i solved it. sorry to have bothered you, i had two copies of script1.sh open and did not realize i changed the one i did not execute. that was pretty useless now, very sry to have wasted your time :(. but thanks anyways, i'm back on track now.
|
Quote:
I hate that "sorry to bother you" thing I've been seeing. That's what we're here for, is to help, if we can. And don't worry... I just went through the same thing last night with a python script I was working on. ;) |
yeah, sometimes its the most obvious things that seem unsolvable... i guess i forgot that 99 out of 100 cases the problem is in front of the screen, not behind it:)
anyways, thanks for the help! |
All times are GMT -5. The time now is 04:00 PM. |