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

Running Allrun script as a superuser

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 11, 2020, 11:37
Default Running Allrun script as a superuser
  #1
New Member
 
Alejandro Valeije
Join Date: Nov 2014
Location: Vigo
Posts: 24
Rep Power: 7
alexvaleije is on a distinguished road
Hello foamers,
I am currently developing a small GUI with Java to run openFOAM cases with it.
This GUI is meant to internally open a new terminal and execute the designated script.

The 5 first lines of my script are the following:

#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions


As you can see, these are the first lines in every Allrun script from every openFoam case.

The problem comes when running this script with the GUI. I think that it tries to execute it as a superuser and it tries to execute the following:

sudo ./RunCase

And the result is:

./RunCase: 5: .: Can't open /bin/tools/RunFunctions

So the question is: is there any way of running these type of scripts as a superuser? I don't think I'm able to change the routine that the GUI does when opening a terminal.

Thanks in advance
alexvaleije is offline   Reply With Quote

Old   February 11, 2020, 14:04
Default
  #2
HPE
Senior Member
 
Herpes Free Engineer
Join Date: Sep 2019
Posts: 298
Rep Power: 3
HPE is on a distinguished road
did you source OpenFOAM etc/bashrc somewhere prior to Allrun?
__________________
Kind regards,
HPE

The OpenFOAM community is the biggest contributor to OpenFOAM; not person A or B. Let's report bugs or issue feature requests in GitLab-OpenFOAM.

Please `design` your questions well. Such effort always pays off well for inquirers and `helpmate`s:
How to create a Minimal, Reproducible Example,
How to give enough info to get help.
HPE is offline   Reply With Quote

Old   February 12, 2020, 05:12
Default
  #3
New Member
 
Alejandro Valeije
Join Date: Nov 2014
Location: Vigo
Posts: 24
Rep Power: 7
alexvaleije is on a distinguished road
Quote:
Originally Posted by HPE View Post
did you source OpenFOAM etc/bashrc somewhere prior to Allrun?
In my /home/user/.bashrc the last line is:

source /opt/openfoam6/etc/bashrc


Since it seems that executing the script as a suepruser is not reading that line, I have tried to write the same line also in the script, before the RunFunctions line, but then, the error message is that the command source is not found.

I have also tried to write sudo source /opt/openfoam6/etc/bashrc alone in a terminal and the error reamins the same: command not found, so I guess the error goes in that direction, but I don't know how to fix it
alexvaleije is offline   Reply With Quote

Old   February 12, 2020, 10:41
Default
  #4
New Member
 
Join Date: Sep 2019
Posts: 9
Rep Power: 2
courant_numero_uno is on a distinguished road
Quote:
Originally Posted by alexvaleije View Post
In my /home/user/.bashrc the last line is:

source /opt/openfoam6/etc/bashrc


Since it seems that executing the script as a suepruser is not reading that line, I have tried to write the same line also in the script, before the RunFunctions line, but then, the error message is that the command source is not found.

I have also tried to write sudo source /opt/openfoam6/etc/bashrc alone in a terminal and the error reamins the same: command not found, so I guess the error goes in that direction, but I don't know how to fix it

See the information here: https://askubuntu.com/questions/5045...nning-a-script
There is something going on with source being a bash command.

Try using this as the first line:
Code:
#!/bin/bash
courant_numero_uno is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Running OpenFOAM case through shell script (bash) ilaj OpenFOAM Programming & Development 2 January 28, 2020 14:14
Problem running Allrun ivanfb95 OpenFOAM 0 March 6, 2017 05:36
How can i activate the Allrun script? spk OpenFOAM 2 October 2, 2011 18:28
Empty Allrun script mwild OpenFOAM Bugs 4 August 25, 2009 03:43
Kubuntu uses dash breaks All scripts in tutorials platopus OpenFOAM Bugs 8 April 15, 2008 08:52


All times are GMT -4. The time now is 10:13.