|
[Sponsors] |
October 29, 2020, 18:30 |
WSL, cannot run Allrun scripts
|
#1 |
Member
Jógvan
Join Date: Feb 2014
Posts: 32
Rep Power: 12 |
Hi,
I am trying to run openFOAM2006 on Ubuntu 20 on WSL (Windows Subsystem for Linux). I can use every OpenFOAM function without issues. However, for some reason I cannot run any of the Allrun scripts. I get the following error: > sh Allrun > Allrun: 2: cd: can't cd to Allrun I've tried multiple distros on WSL, but all show the same error. Does anyone know what the issue might be? - Jógvan |
|
October 30, 2020, 04:10 |
|
#2 |
Senior Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20 |
try
Code:
./Allrun |
|
October 30, 2020, 04:30 |
|
#3 |
Member
Jógvan
Join Date: Feb 2014
Posts: 32
Rep Power: 12 |
Thanks for your feedback.
That produces the same error. |
|
October 31, 2020, 17:18 |
|
#4 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14 |
Can you paste the contents of your Allrun script? Maybe something wrong inside it? try put
Code:
echo "hello world" |
|
November 1, 2020, 10:29 |
|
#5 | |
Member
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9 |
Quote:
It seems to me like the script is running, and you are getting an error message from line 2 of the script. You seem to be trying to change the working directory to Allrun, which is a file. |
||
November 2, 2020, 04:40 |
|
#6 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14 |
Indeed - that was my thought.
|
|
November 2, 2020, 16:52 |
|
#7 |
Member
Jógvan
Join Date: Feb 2014
Posts: 32
Rep Power: 12 |
Yes, it is simply line 2 that is the issue.
All Allrun files in the tutorials have the following line 2: Code:
cd ${0%/*} || exit 1 # Run from this directory Do you know what the purpose of that line is? |
|
November 2, 2020, 16:59 |
|
#8 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14 |
Probably simplest to point you at:
https://stackoverflow.com/questions/...0-mean-in-bash $0 expands to the name of the script, with full path; the rest of the stuff in the brackets is pattern matching to strip off the file name, leaving you with just the name of the folder that the script sits in. |
|
November 3, 2020, 09:35 |
|
#9 | |
Member
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9 |
Quote:
I usually write my Allrun scripts from scratch instead of modifying the one in the tutorial case. I am not a bash expert, but the line does what the comment says - run from the directory that the script is in, or in other words, set the current working directory to the directory that the script is in. This does nothing if you are calling the script from the folder it is in, like Code:
bash ./Allrun But if you call it from a different directory, like: Code:
bash ./run/case_folder/Allrun Code:
python ./scripts/post_process.py '.' is the current working directory and not the directory of the script. I think this line is included in the Allrun script to avoid errors with relative directories like what I described above. There might be other advantages to leaving that line there as well. The script might work without errors without removing this line if you rename it to 'Allrun.sh'. |
||
August 30, 2023, 22:35 |
Commands for novice Linux users
|
#10 |
New Member
Corbin G
Join Date: Oct 2022
Location: Midwest, USA
Posts: 11
Rep Power: 4 |
In case anyone else is new to Linux like me, this is what I did to run with the script files:
Software: Windows 11, WSL, Ubuntu 18.04, OpenFOAM v2206 Command: Code:
bash ./Allclean; bash ./Allrun > log1 & |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Reporting a bug in Allrun script on wingMotion case | i.sabahi | OpenFOAM Bugs | 0 | June 10, 2018 10:00 |
How to specify machine in Allrun files | killsecond | OpenFOAM Running, Solving & CFD | 3 | May 18, 2018 16:29 |
simpleFoam parallel | AndrewMortimer | OpenFOAM Running, Solving & CFD | 12 | August 7, 2015 19:45 |
Cannot run phoenix on linux opensuse 13.1 kde | mabal | Phoenics | 0 | June 15, 2014 07:16 |
[mesh manipulation] Cannot get refineMesh to run in parallel | smschnob | OpenFOAM Meshing & Mesh Conversion | 2 | June 3, 2014 12:20 |