On 02/06/2019 7:57 PM, Amarjit S. Chandhial wrote:
> ... but with a complete reproducible example with step-by-step guidelines
With these four steps, I've the complete example running on an OS X
(10.7) box, where the (Apple) Server Tools are installed.
$ gfortran sumform.f90 -o sumform
$ sudo install -p -m 755 sumform
/Library/Webserver/CGI-Executables/example1.html
$ gfortran example1.f90 -o example1
$ sudo install -p -m 755 example1
/Library/Webserver/CGI-Executables/example1.exe
Also, you said you know how to add a ScriptAlias ( /cgi-bin/ ... ).
In my case, I had to change the Fortran statements that read the
response passed from the WEB Server to the executable. You likely
have to further work on it because the statements that parse the
two numbers entered by the user are somewhat fragile :-)
IMHO, any other problems you perhaps face are either Apache or Mojave
specific.
Ev. Drikos
---------------
$ cat sumform.f90
WRITE(*,'(''Content-type: text/html'',//)') !
WRITE(*,*) '<html><body>'
write(*,*) '<p>Enter numbers in the two boxes, and press the
"Calculate Sum" button:</p>'
write(*,*) '<form action="/cgi-bin/example1.exe" method="post">'
write(*,*) '<p>First number: <input type="text" name="number1"
id="num1" value="" size="10" /> </p>'
write(*,*) '<p>Second number: <input type="text" name="number2"
id="num2" value="" size="10" /> </p>'
write(*,*) '<input type="submit" value=" Calculate Sum" />'
write(*,*) '</form>'
WRITE(*,*) '</body></html>'
END
---------------
$ cat example1.f90
program example1
implicit none
! ..(1) Declarations
! ----------------
character (len=255) :: LineIn = ' '
character (len=10) :: string = ' '
integer :: lenLineIn, startValue, endValue, ichar, istat
real :: sum_of_numbers, var1, var2
sum_of_numbers = 0 ! add the numbers together
! ..(5) Send a header to the browser, identifying
! the type of information that will be sent.
! ---------------------------------------------
WRITE(*,'(''Content-type: text/html'',//)')
! ..(6) Write the html results page to the browser,
! with the sum of the two numbers.
! -----------------------------------------------
WRITE(*,'(1X,''<html><body>'')')
READ(*, *, iostat=istat) LineIn
if ( istat == 0 ) then
! write (*,*) "'" // LineIn // "'"
! ..(4a) Locate and read the value of 'number1' from LineIn
! ------------------------------------------------------
startValue = INDEX(LineIn,'number1=') + 8
endValue = startValue + INDEX(LineIn(startValue:),'&') - 2
READ(LineIn(startValue:endValue),*) var1
! write (*,*) "var1=", var1
! ..(4b) Locate and read the value of 'number2' from LineIn
! ------------------------------------------------------
startValue = INDEX(LineIn,'number2=') + 8
READ(LineIn(startValue:),*) var2
! write (*,*) "var2=", var2
sum_of_numbers = var1 + var2 ! add the numbers together
WRITE(*,100) sum_of_numbers
else
write (*,*) "read iostat=", istat
endif
WRITE(*,'(1X,''</body></html>'')')