R
Rob Boellaard
Hi all,
First post here, I hope it is in the right place. I am new to Ruby,
and I am trying to write a simple cgi script.
I want to execute a method inside a cgi script, but I constantly get
the error:
[Sat Apr 12 12:49:39 2008] [error] [client 62.163.186.111] Premature end
of script headers: /Library/WebServer/CGI-Executables/biblio/main.rb
It doesn't matter if I just define the method locally in the script,
or if I create a class, and define the method there.
If I comment out the line: Person.new().saveNewPerson("bla",
"blabla"), the script properly returns the html with "Done"
If I copy the class and the command calling the class, and put them in
separate script (without cgi) and run that script, the "bla" and
"blabla" are written to the Person file as expected.
#!/usr/bin/ruby
class Person
def saveNewPerson(aFirstName, aLastName)
file = File.open("/Users/somePath/Person.xml", "r+")
file.puts(aFirstName)
file.puts(aLastName)
end
end
require "cgi"
cgi = CGI.new("html4")
#saveNewPerson(cgi.params["firstName"], cgi.params["lastName"])
Person.new().saveNewPerson("bla", "blabla")
cgi.out {
cgi.html {
cgi.body {
cgi.p {"Done"}
}
}
}
thanks a lot for your help,
Rob
First post here, I hope it is in the right place. I am new to Ruby,
and I am trying to write a simple cgi script.
I want to execute a method inside a cgi script, but I constantly get
the error:
[Sat Apr 12 12:49:39 2008] [error] [client 62.163.186.111] Premature end
of script headers: /Library/WebServer/CGI-Executables/biblio/main.rb
It doesn't matter if I just define the method locally in the script,
or if I create a class, and define the method there.
If I comment out the line: Person.new().saveNewPerson("bla",
"blabla"), the script properly returns the html with "Done"
If I copy the class and the command calling the class, and put them in
separate script (without cgi) and run that script, the "bla" and
"blabla" are written to the Person file as expected.
#!/usr/bin/ruby
class Person
def saveNewPerson(aFirstName, aLastName)
file = File.open("/Users/somePath/Person.xml", "r+")
file.puts(aFirstName)
file.puts(aLastName)
end
end
require "cgi"
cgi = CGI.new("html4")
#saveNewPerson(cgi.params["firstName"], cgi.params["lastName"])
Person.new().saveNewPerson("bla", "blabla")
cgi.out {
cgi.html {
cgi.body {
cgi.p {"Done"}
}
}
}
thanks a lot for your help,
Rob