CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

WSL, cannot run Allrun scripts

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 29, 2020, 18:30
Default WSL, cannot run Allrun scripts
  #1
Member
 
Jógvan
Join Date: Feb 2014
Posts: 32
Rep Power: 12
Jeggi is on a distinguished road
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
Jeggi is offline   Reply With Quote

Old   October 30, 2020, 04:10
Default
  #2
Senior Member
 
JNSN's Avatar
 
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 144
Rep Power: 20
JNSN is on a distinguished road
try
Code:
./Allrun
JNSN is offline   Reply With Quote

Old   October 30, 2020, 04:30
Default
  #3
Member
 
Jógvan
Join Date: Feb 2014
Posts: 32
Rep Power: 12
Jeggi is on a distinguished road
Thanks for your feedback.
That produces the same error.
Jeggi is offline   Reply With Quote

Old   October 31, 2020, 17:18
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14
Tobermory will become famous soon enough
Can you paste the contents of your Allrun script? Maybe something wrong inside it? try put
Code:
echo  "hello world"
as the first line to see if the script is running - that will tell you then if the error is inside the script, as opposed to an arror with just running the script.
Tobermory is offline   Reply With Quote

Old   November 1, 2020, 10:29
Default
  #5
RGS
Member
 
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9
RGS is on a distinguished road
Quote:
Originally Posted by Jeggi View Post
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

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.
RGS is offline   Reply With Quote

Old   November 2, 2020, 04:40
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14
Tobermory will become famous soon enough
Indeed - that was my thought.
Tobermory is offline   Reply With Quote

Old   November 2, 2020, 16:52
Default
  #7
Member
 
Jógvan
Join Date: Feb 2014
Posts: 32
Rep Power: 12
Jeggi is on a distinguished road
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
If I remove this line, everything works as intended.
Do you know what the purpose of that line is?
Jeggi is offline   Reply With Quote

Old   November 2, 2020, 16:59
Default
  #8
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 747
Rep Power: 14
Tobermory will become famous soon enough
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.
Tobermory is offline   Reply With Quote

Old   November 3, 2020, 09:35
Default
  #9
RGS
Member
 
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9
RGS is on a distinguished road
Quote:
Originally Posted by Jeggi View Post
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
If I remove this line, everything works as intended.
Do you know what the purpose of that line is?

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
and if the script is written to call other scripts with directories defined relative to it's directory, then those scripts cannot be found. For instance, if there is a line:


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'.
RGS is offline   Reply With Quote

Old   August 30, 2023, 22:35
Default Commands for novice Linux users
  #10
New Member
 
Corbin G
Join Date: Oct 2022
Location: Midwest, USA
Posts: 11
Rep Power: 4
CorbinMG is on a distinguished road
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 &
CorbinMG is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 01:18.