CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   why not reading from script? (http://www.cfd-online.com/Forums/openfoam-programming-development/117080-why-not-reading-script.html)

immortality May 1, 2013 15:29

why not reading from script?
 
2 Attachment(s)
I have put this script (plot)on my desktop as well as some other simple scripts and have given its address to bashrc as below:
Code:

PATH=$PATH:/home/ehsan/Desktop/codes
other scripts are working well but plot doesn't by this error:
Code:

ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ plot rhoCentralFoam
plot: rhoCentralFoam: No such file or directory
plot: ignoring this file

(for example report file performs fine but plot doesn't)

haakon May 2, 2013 02:50

Try to use the export command in .bashrc to make the variable global:
Code:

export PATH="$PATH:/home/ehsan/Desktop/codes"

immortality May 2, 2013 05:54

thanks.
but the error is repeated.
Code:

ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ plot rhoCentralFoam
plot: rhoCentralFoam: No such file or directory
plot: ignoring this file


haakon May 2, 2013 06:15

In the top of your plot script, you have the shebang:
Code:

#! /bin/sh
try to remove the space, such that it become
Code:

#!/bin/sh
Also make sure that you have made the script executable, by calling
Code:

chmod +x plot
from the folder with the plot script.

immortality May 2, 2013 08:31

I removed space.yes its executable.doesn't perform.:confused:

wyldckat May 2, 2013 08:58

Greetings to all!

@Ehsan: What happens if you run the contents of the script directly on the command line? Namely:
Code:

pyFoamPlotRunner.py --hardcopy --with-courant --progress --no-pickled-file rhoCentralFoam
Best regards,
Bruno

immortality May 2, 2013 09:25

dear Bruno I have been using that untill now and thought it will be better to do that by a short command and script but it doesn't work.

wyldckat May 2, 2013 09:32

Quote:

Originally Posted by immortality (Post 424667)
dear Bruno I have been using that untill now and thought it will be better to do that by a short command and script but it doesn't work.

Mmm... strange... OK, then try changing the first line:
Code:

#!/bin/sh
To:
Code:

#!/bin/bash
If it still doesn't work, try:
Code:

#!/bin/bash
which $1

It should tell you where rhoCentralFoam is located, namely it should give the same as running on the command line:
Code:

which rhoCentralFoam

immortality May 2, 2013 10:15

no.which command doesn't work in script but work in terminal:
Code:

ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ plot rhoCentralFoam
plot: rhoCentralFoam: No such file or directory
plot: ignoring this file
ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ which rhoCentralFoam
/opt/openfoam220/platforms/linux64GccDPOpt/bin/rhoCentralFoam


wyldckat May 2, 2013 10:25

I finally understand what's happening... try running:
Code:

which plot
#or
type plot

It will probably tell you it's located at "/usr/bin/plot"!

The solution is simple: rename your "plot" script!

immortality May 2, 2013 11:04

yes that message was shown.then its name is like other script in ubuntu?
but other names don't work:
Code:

ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ do rhoCentralFoam
bash: syntax error near unexpected token `do'
ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ runPlot rhoCentralFoam
ehsan@Ehsan-com:~/Desktop/WR_Main_Central$


wyldckat May 2, 2013 11:26

What does the following command output?
Code:

which runPlot

immortality May 2, 2013 11:37

it knows the path:
Code:

ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ which runPlot
/home/ehsan/Desktop/codes/runPlot

but:confused:

wyldckat May 2, 2013 14:09

OK, then confirm the contents of the file... I don't know what it looks like at this point.

If it all makes sense, try changing the first line to this:
Code:

#!/bin/bash -x
It should show you what it's doing when the script is executed.

immortality May 2, 2013 14:25

that says this::D
Code:

ehsan@Ehsan-com:~/Desktop/WR_Main_Central$ runPlot rhoCentralFoam
+ solver=rhoCentralFoam
+ pyFoamPlotRunner.py --hardcopy --with-courant --progress --no-pickled-file rhoCentralFoam
Killing PID 14778
 PyFoam WARNING on line 232 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Execution/FoamThread.py : Process 14778 was already dead
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/14778/status'


immortality May 2, 2013 14:44

resolved!
sorry,i had changed a postProceesing function meanwhile and didn't test full pyFoam command it terminal after that change.
then it must have been resolved when I had changed its header to
Code:

#!/bin/bash
:D
but i learned some more things!;)
now a simple question how can I set number of processors in line like this:
runPlot 4 rhoCentralFoam
what should i replace for 4 in this code? :
Code:

#!/bin/bash
solver=$1
pyFoamPlotRunner.py --hardcopy --with-deltat --with-courant --procnr=4 $solver


wyldckat May 2, 2013 15:23

Quote:

Originally Posted by immortality (Post 424789)
now a simple question how can I set number of processors in line like this:
runPlot 4 rhoCentralFoam
what should i replace for 4 in this code? :
Code:

#!/bin/bash
solver=$1
pyFoamPlotRunner.py --hardcopy --with-deltat --with-courant --procnr=4 $solver


I guess you haven't studied properly the other script I made for merging data and the studying references I gave... Anyway, it's very simple:
Code:

#!/bin/bash
solver=$2
pyFoamPlotRunner.py --hardcopy --with-deltat --with-courant --procnr=$1 $solver



All times are GMT -4. The time now is 17:27.