bash - Using selfwritten .sh file in another .sh file -
i writing small .sh program in bash.
the problem extremely simple, i.e, dind primefactors of number. i've done written .sh file check if number prime or not. here code :
if [ $# -ne 1 ]; exit fi number=$1 half=$(($number / 2)) (( i=2;i<$half;i++ )) rem=$(($number % $i)) if [ $rem -eq 0 ]; echo "0" exit fi done echo "1"
and second .sh file generate prime factors :
clear echo "enter number : " read number half=$(($number / 2)) for(( i=1;i<=$half;i++ )) rem=$(($number % $i)) if [ $rem -eq 0 ]; ok=`prime.sh $rem` if [ "$ok" == "1" ]; echi $i fi fi done
this line ,
ok=`prime.sh $rem`
gives following error :
primefactor.sh: line 10: prime.sh: command not found
so, not possible divide program smaller modules , use in other modules other programming languages ? on how achieve helpful.
call script this:
ok=`./prime.sh $rem`
Comments
Post a Comment