1. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 10, 2001
- 491 views
Thank you for the function (I'll need to study it more, but I get the gist), but I have no open routines, etc. I fully understand the requirements for cgi (spent the last 7 days looking up the specs, etc.). I must not be explaining myself very well (my biggest problem). My program is *only* this: Filename sendimage.exw [code] puts (1, "Location: /IsPlaying.bmp") [end code] When bound into a win32 .exe this works. My bitmap is returned to the browser to be displayed. If I update the bitmap and browse to the URL (http://server/cgi-bin/image.exe) the browser updates accordingly, instead of displaying the locally cached image, which might not be what I want displayed. It is all working. I know I have a lot to add, but I don't want to do anything else until I solve this problem: How do I prevent the console from opening and closing whenever the browser requests the image? My goal is a program that takes the currently playing song out of Winamp and turns it into an image. This would allow radio stations, and forum signatures to display a dynamic image of whatever they are playing at the moment to the users. If the console window opens everytime the program runs (could get hunderds of hits an hour), this is a BIG problem and there is no point in refining the cgi code into elegance. I'll just have to do it in php or perl, which I'm trying to avoid doing, I want a "pure" solution, one that depends on as little third party software as possible. Perhaps a translation to C and compiling that? Thanks for trying, I really do appreciate it -=Cassidy=- rolf.schroeder at desy.de wrote: > Cassidy Napoli wrote: > > > > .... So I am guessing tthat there > > isn't a way to get Euphoria to execute win32 code without a window? > > > You have to write the CGI program without any window (open etc.) > routines, you need > puts() as std_out(). Euphoria has no std_in() function. Use the GET > method instead and read the CGI environment by 'getenv("QUERY_STRING")'. > If your WWW-CGI server writes the data transferred by POST into a file, > and if it offers you the file name via the CGI environment you may use > also the POST method. Attached is a function for the > XITAMI server to read the data sent to the server server: > > integer len, fn -- -2 = REQUEST_METHOD fails > -- -3 = unknown error > method = getenv("QUERY_METHOD") > if atom(method) then > return -2 > elsif equal(method,"POST") then > s = value(getenv("CONTENT_LENGTH")) > if s[1] = GET_SUCCESS then > len = s[2] > s = "..\\" & getenv("CGI_STDIN") > fn = open("..\\..\\" & getenv("CGI_STDIN"),"rb") > > if fn < 0 then > return "Open failed! " & s > end if > s = get_bytes(fn,len) > close(fn) > return s > else > return s[1] > end if > elsif equal(method,"GET") then > return getenv("QUERY_STRING") > else > return -3 > end if > end function > > Have a nice day, Rolf > >
2. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 10, 2001
- 449 views
It doesn't look like a win32 window...it's a console window (you know...a dos box) and it closes on termination (which is practically immediately, because all it does is spit out 1 puts() ). But yes, it opens if I send a request to my cgi program. I could live with this, but I want to distribute the program, and it doesn't do any good if you're trying to get work done and a dos-box keeps opening and shutting on you. r.schr at t-online.de wrote: > Cassidy Napoli wrote: > > > > ... How do I > > prevent the console from opening and closing whenever the browser > > requests the image? > > > > Does it mean that a new win32 window opens if you send a request to your > CGI program? > > Have a nice day, Rolf > >
3. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 10, 2001
- 449 views
I'm sure it is executing on the server. How else would the browser know what image to display? puts(1,"Location: /resource.xxx\n\n") This tells the browser to load whatever the resource is, from the server running the cgi. This is in place of content-type. Nothing else needs to be sent to the browser, the browser just gets whatever is at the location and displays that. It could be an image, video, another webpage, whatever. I can pass an absolute to it as well: puts(1,"Location: http://www.server.com/resource.xxx\n\n") I would only need puts(1,"Content-Type: text/html\n\n") if I were about to create a dynamic webpage. I would follow that with: puts(1,"<html><head>...") etc. Then I could script the page to look like anything. But this isn't what I'm trying to do. The cgi code is working...I'm trying to eliminate the window popping up that would make my program irritating to run on a regular users desktop. It needs to run silently. -=Cassidy=- r.schr at t-online.de wrote: > Cassidy Napoli wrote: > > > > I could live with this, but I want to distribute the program, and it > > doesn't do any good if you're trying to get work done and a dos-box > > keeps opening and shutting on you. > > > Are you sure your program runs on the CGI server? It look like it runs > simply under your local CMD window in DOS mode. The first output line in > your CGI program has to be: > > puts(1,"Content-Type: text/html\n\n") > > Do you have this starting line? > > Have a nice day, Rolf > >
4. RE: cgi
- Posted by tacitus <indorlaw at zdnetonebox.com> Oct 10, 2001
- 450 views
hi cassidy i know nothing about cgi, but have you tried:- 1. experimenting with the stuff in the RefMan under the library function free_console(), which also refers to a WinAPI function FreeConsole(). in a different context, i've used this to make the console disappear before it becomes apparent to the user. 2. setting the file properties to "Run Minimised". this normally causes a dos program to create only the taskbar presence and not the console. regards tacitus Cassidy Napoli wrote: > I'm sure it is executing on the server. How else would the browser know > > what image to display? > > puts(1,"Location: /resource.xxx\n\n") > This tells the browser to load whatever the resource is, from the server > > running the cgi. This is in place of content-type. Nothing else needs > to be sent to the browser, the browser just gets whatever is at the > location and displays that. It could be an image, video, another > webpage, whatever. > > I can pass an absolute to it as well: > puts(1,"Location: http://www.server.com/resource.xxx\n\n") > > I would only need puts(1,"Content-Type: text/html\n\n") if I were about > to create a dynamic webpage. I would follow that with: > puts(1,"<html><head>...") etc. Then I could script the page to look > like anything. But this isn't what I'm trying to do. The cgi code is > working...I'm trying to eliminate the window popping up that would make > my program irritating to run on a regular users desktop. It needs to > run silently. > > -=Cassidy=- > > r.schr at t-online.de wrote: > > Cassidy Napoli wrote: > > > > > > I could live with this, but I want to distribute the program, and it > > > doesn't do any good if you're trying to get work done and a dos-box > > > keeps opening and shutting on you. > > > > > Are you sure your program runs on the CGI server? It look like it runs > > simply under your local CMD window in DOS mode. The first output line in > > your CGI program has to be: > > > > puts(1,"Content-Type: text/html\n\n") > > > > Do you have this starting line? > > > > Have a nice day, Rolf > > > >
5. RE: cgi
- Posted by Kat <gertie at PELL.NET> Oct 10, 2001
- 454 views
On 10 Oct 2001, at 15:48, Cassidy Napoli wrote: > > Thank you for the function (I'll need to study it more, but I get the > gist), but I have no open routines, etc. I fully understand the > requirements for cgi (spent the last 7 days looking up the specs, etc.). > I must not be explaining myself very well (my biggest problem). My > program is *only* this: > > Filename sendimage.exw > [code] > puts (1, "Location: /IsPlaying.bmp") ^^Did you try commenting out this line?^^ Kat
6. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 11, 2001
- 462 views
rolf.schroeder at desy.de wrote: > Hi Cassidy, > > is it absolutely clear that the program line: > > puts(1,"Location: /resource.xxx\n\n") > > is the first output of the program at the CGI SERVER SIDE called by the > client browser? > > I append an example including an image. make a DIR 'test' under > 'cgi-bin' on your CGI server, copy all files into the 'test' dir, run > 'bindw test' to create en win32 executable and call from your browser: > > 'http://ServerName/cgi-bin/test/test.exe' > > enjoy! > > Have a nice day, Rolf Rolf, No it is NOT NECESSARY. This is the *working* version of the cgi half of my program: image.ex (image.exe when bound) -------- without warning procedure main() object request, server sequence outstring request = getenv("QUERY_STRING") server = getenv("SERVER_URL") if sequence(request) then outstring = "Location: " & server & request & "\n\n" puts (1, outstring) end if end procedure main() -------- You need images in your default directory, then (running Xitami, anyway) point your browser to http://yourserver/cgi-bin/image?imagename.gif And it runs fine...I get back whatever image exist at iamgename.gif. This was my goal and this is what it is doing. The other half of my program is what generates the .gifs. So now, everytime Winamp changes songs, the image is changed. And everytime someone requests http://myserver/cgi-bin/image?isplaying.gif they get the currently playing song, even if they had an older isplaying.gif in browser cache. As soon as I get the configs finished I'll send you a copy so you can see exactly what is going on. Did you read the cgi information from http://hoohoo.ncsa.uiuc.edu/cgi/out.html ? In any event, thank you for your effort, but I've got it working now, for sure. I'm using it :). -=Cassidy=-
7. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 11, 2001
- 444 views
Sorry, my first statement "It is NOT NECESSARY" wasn't supposed to be there. Yes, I'm now sure that it is the first line and that everything else is working. It was my poor choice of webservers that was causing the most headaches. Cassidy Napoli wrote: > rolf.schroeder at desy.de wrote: > > Hi Cassidy, > > > > is it absolutely clear that the program line: > > > > puts(1,"Location: /resource.xxx\n\n") > > > > is the first output of the program at the CGI SERVER SIDE called by the > > client browser? > > > > I append an example including an image. make a DIR 'test' under > > 'cgi-bin' on your CGI server, copy all files into the 'test' dir, run > > 'bindw test' to create en win32 executable and call from your browser: > > > > 'http://ServerName/cgi-bin/test/test.exe' > > > > enjoy! > > > > Have a nice day, Rolf > > Rolf, > No it is NOT NECESSARY. This is the *working* version of the cgi half > of my program: > > image.ex (image.exe when bound) > -------- > without warning > > procedure main() > object request, server > sequence outstring > request = getenv("QUERY_STRING") > server = getenv("SERVER_URL") > if sequence(request) then > outstring = "Location: " & server & request & "\n\n" > puts (1, outstring) > end if > end procedure > > main() > -------- > You need images in your default directory, then (running Xitami, anyway) > > point your browser to > > http://yourserver/cgi-bin/image?imagename.gif > > And it runs fine...I get back whatever image exist at iamgename.gif. > This was my goal and this is what it is doing. > The other half of my program is what generates the .gifs. So now, > everytime Winamp changes songs, the image is changed. And everytime > someone requests > > http://myserver/cgi-bin/image?isplaying.gif > > they get the currently playing song, even if they had an older > isplaying.gif in browser cache. As soon as I get the configs finished > I'll send you a copy so you can see exactly what is going on. > > Did you read the cgi information from > http://hoohoo.ncsa.uiuc.edu/cgi/out.html ? > > In any event, thank you for your effort, but I've got it working now, > for sure. I'm using it :). > > -=Cassidy=- > >
8. RE: cgi
- Posted by Ryan Johnson <rywilly at rywilly.com> Oct 12, 2001
- 458 views
I don't understand cgi, but I was thinking about trying it one of these days... Anyway, although I don't know cgi, I do know that from my experience, when you run a euphoria program (in windows), it does not create a prompt window unless it needs to. Correct me if I'm wrong, but when you use "puts(1, "text")", doesn't "1" represent the screen? And when you put to the screen, Euphoria creates a console window so it can "puts" to it. If you want to put to an open file, you would use whatever number represents that open file, which should be a number other than 1. Are you putting to a file? Maybe you should use the number 2. Am I helping? Or should I just be quiet now? :) rolf.schroeder at desy.de wrote: > Cassidy Napoli wrote: > > ... > > puts(1,"Location: /resource.xxx\n\n") > > This tells the browser to load whatever the resource is, from the server > > running the cgi. This is in place of content-type. Nothing else needs > > to be sent to the browser, the browser just gets whatever is at the > > location and displays that. It could be an image, video, another > > webpage, whatever. > > ... > > Hi Cassidy, > > is it absolutely clear that the program line: > > puts(1,"Location: /resource.xxx\n\n") > > is the first output of the program at the CGI SERVER SIDE called by the > client browser? > > I append an example including an image. make a DIR 'test' under > 'cgi-bin' on your CGI server, copy all files into the 'test' dir, run > 'bindw test' to create en win32 executable and call from your browser: > > 'http://ServerName/cgi-bin/test/test.exe' > > enjoy! > > Have a nice day, Rolf > >
9. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 12, 2001
- 464 views
1 represent stdout, which is *usually* the screen, but in the case of a web server running a cgi stdout points to the webserver, which in turn (depending on what you've sent it) sends that data on to the client broswer. In my case "Location: /resource.xxx\n\n", tells the webserver to send resource.xxx (ispalying.gif) to the client, rather then html code, which would be "Content-Type: text/html\n\n". I got it working, it was the webserver (www.analogx.com, SimpleServer WWW) that was causing the trouble. I switched to Xitami, and have it working correctly now. I was trying to use the AnalogX server beause it's small and super easy to set up (follows my program methodology: KISS - Keep It Simple, Stupid!). But Xitami is a really good open source server, that came highly recommended (by Euphoria members, no less :) ), so Xitami it is. And Xitami isn't hard to setup and use, it's just *more* complicated than AnalogX. Thanks for the suggestion, anyway. -=Cassidy=- Ryan Johnson wrote: > I don't understand cgi, but I was thinking about trying it one of these > days... > Anyway, although I don't know cgi, I do know that from my experience, > when you run a euphoria program (in windows), it does not create a > prompt window unless it needs to. > Correct me if I'm wrong, but when you use "puts(1, "text")", doesn't "1" > > represent the screen? And when you put to the screen, Euphoria creates a > > console window so it can "puts" to it. If you want to put to an open > file, you would use whatever number represents that open file, which > should be a number other than 1. Are you putting to a file? Maybe you > should use the number 2. > Am I helping? Or should I just be quiet now? :)
10. RE: cgi
- Posted by Kat <gertie at PELL.NET> Oct 12, 2001
- 443 views
On 12 Oct 2001, at 13:51, Ryan Johnson wrote: > > I don't understand cgi, but I was thinking about trying it one of these > days... > Anyway, although I don't know cgi, I do know that from my experience, > when you run a euphoria program (in windows), it does not create a > prompt window unless it needs to. > Correct me if I'm wrong, but when you use "puts(1, "text")", doesn't "1" > represent the screen? And when you put to the screen, Euphoria creates a > console window so it can "puts" to it. Which is why i asked if Cassidy had tried commenting out that line, hinting that all the puts(1,..) lines should be commented out. But no one replied. The dos and win stdout can't be redirected, cept thru dos's ">" and "|" batch commands, or i could be wrong again..... Kat
11. RE: cgi
- Posted by Cassidy Napoli <gonzotek at yahoo.com> Oct 12, 2001
- 450 views
Sorry, By the time I read your message I had it working. The puts is ESSENTIAL to the cgi. All my headaches were because the webserver I chose to test my cgi out with didn't properly support a binary win32 cgi. Switching to Xitami fixed this. STDIN and STDOUT are usually the screen. But if a webserver is calling the program (rather than dos/windows) the STDIN/OUT should travel between the client browser and the webserver. Did that make any sense? I spent a week learning the basics of cgi so I could do this, and all the while I had the code right, but the webserver couldn't handle it properly :x -=Cassidy=- --- Kat <gertie at PELL.NET> wrote: > > On 12 Oct 2001, at 13:51, Ryan Johnson wrote: > > > > > I don't understand cgi, but I was thinking about > trying it one of these > > days... > > Anyway, although I don't know cgi, I do know that > from my experience, > > when you run a euphoria program (in windows), it > does not create a > > prompt window unless it needs to. > > Correct me if I'm wrong, but when you use "puts(1, > "text")", doesn't "1" > > represent the screen? And when you put to the > screen, Euphoria creates a > > console window so it can "puts" to it. > > Which is why i asked if Cassidy had tried commenting > out that line, hinting > that all the puts(1,..) lines should be commented > out. But no one replied. The > dos and win stdout can't be redirected, cept thru > dos's ">" and "|" batch > commands, or i could be wrong again..... > > Kat > > > > > =====