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 Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 11, 2020, 10:37
Default Running Allrun script as a superuser
  #1
Member
 
Alejandro Valeije
Join Date: Nov 2014
Location: Spain
Posts: 52
Rep Power: 11
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, 13:04
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
did you source OpenFOAM etc/bashrc somewhere prior to Allrun?
HPE is offline   Reply With Quote

Old   February 12, 2020, 04:12
Default
  #3
Member
 
Alejandro Valeije
Join Date: Nov 2014
Location: Spain
Posts: 52
Rep Power: 11
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, 09:41
Default
  #4
New Member
 
Join Date: Sep 2019
Posts: 17
Rep Power: 6
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


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 13:14
Problem running Allrun ivanfb95 OpenFOAM 0 March 6, 2017 04:36
How can i activate the Allrun script? spk OpenFOAM 2 October 2, 2011 17:28
Empty Allrun script mwild OpenFOAM Bugs 4 August 25, 2009 02:43
Kubuntu uses dash breaks All scripts in tutorials platopus OpenFOAM Bugs 8 April 15, 2008 07:52


All times are GMT -4. The time now is 12:49.