Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

opening the cd rom

by Anonymous Monk
on Oct 03, 2004 at 19:30 UTC ( #396047=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

There was a site I knew of about a year ago that would open your cd rom when you loaded the site. I thought this was pretty neat but I have no idea what language they used to do it. Chances are it was JavaScript but I was wondering if there was any way we could do that using CGI?

Not sure if any of you seen the page but it said it was a cup holder (LOL). Anyway, could this be done in CGI?

Replies are listed 'Best First'.
Re: opening the cd rom
by ambrus (Abbot) on Oct 03, 2004 at 20:10 UTC

    Forgetting about the web part of the question first, let me note how to open the cdrom from a locally run program, in linux. I show this just because it's not obvious even this way.

    { use Fcntl; sysopen my $f, "/dev/hdc", O_RDONLY|O_NONBLOCK or die "open + $?"; ioctl $f, 0x5309, 0 or die "ioctl $!"; }

    The trick here is to use O_NONBLOCK. You have to substitute "/dev/hdc" with the actual cdrom device of course. You can probably find it out with the {set,get,end}fsent C functions, but I don't know how to access those from perl.

Re: opening the cd rom
by TedPride (Priest) on Oct 03, 2004 at 20:24 UTC
    CGI: (Common Gateway Interface) -- A set of rules that describe how a Web Server communicates with another piece of software on the same machine, and how the other piece of software (the 'CGI program') talks to the web server.

    CGI scripts are run on the server, and have no control over the client. Therefore, you can't use CGI to make your computer do things.

Re: opening the cd rom
by zakzebrowski (Curate) on Oct 03, 2004 at 20:21 UTC
    It was not CGI, it was vbscript as I recall. CGI is basically any script which produces a web page. Therefore, CGI is lower level than VB script or javascript, which is only rendered by the browser at view time. Also, CGI is not necesiarially perl. It could be (pick language of choice:) asp/jsp/c/bash/cpp. Cheers.


    ----
    Zak - the office
Re: opening the cd rom
by tachyon (Chancellor) on Oct 03, 2004 at 23:58 UTC

    ...could this be done in CGI?

    No, this sort of code expliots security holes, primarily in Microsoft's ActiveX technology, but also in Java and other Plugins. Javascript has essentially no Operating System access by design and while it can do some very annoying stuff is *mostly harmless*. See this article for some background.

    The latest security hole is in M$ handling of JPEG files. See this article Or just go have a look at this image ;-)

    LOL

    You think? Perhaps it is amusing that the World's largest software company releases software that lets anyone anywhere do anything to your PC.

      You know the old saying: Open my CD tray through a web browser once, shame on Bill G; open my CD tray twice shame on me.

        ++ Fletch!

        -Theo-
        (so many nodes and so little time ... )

Re: opening the cd rom
by pg (Canon) on Oct 04, 2004 at 02:16 UTC

    As to open CDROM, you can call win api: (This is not about CGI ;-)

    use Win32::API; use strict; use warnings; my $f = Win32::API->new("winmm", "mciSendString", "PPNN", "N"); my $ret = ' ' x 127; my $return = $f->Call('set CDAudio door open', $ret, 127, 0);

      Of course using this in a CGI would open the tray on your server. Might even be somewhat useful as a primitive hit counter, or at least it could amuse the guys in the server room . . . :)

        That's just plain wicked, Fletch. I love it!
        ggg
Re: opening the cd rom
by talexb (Canon) on Oct 03, 2004 at 22:03 UTC

    I heard about that from my stepson Matt -- he was in a chat room and some l33t d00d was doing that to all of the people in the room. Except for Matt.

    d00D: Hey! You're not running windows, are you?
    Matt: Nope -- Mandrake 10. ;)

    That definitely put a smile on *my* face.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: opening the cd rom
by sgifford (Prior) on Oct 04, 2004 at 04:52 UTC
    Something like this might work:
    print "Content-type: text/html\n\n"; print "<h1><blink>Press CD-ROM Eject Button Now!</blink></h1>\n";
Re: opening the cd rom
by muba (Priest) on Oct 03, 2004 at 20:05 UTC
    I agree with the statement "users are dump/stupid/whatever". So am I. So are you. But nobody is that stupid! Everyone who uses a computer knows how to open the cd rom drive. Programs and websites should not change things unsollicited.

    My $0.02.




    "2b"||!"2b";$$_="the question"
    Besides that, my code is untested unless stated otherwise.
    One more: please review the article about regular expressions (do's and don'ts) I'm working on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://396047]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-12-03 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (27 votes). Check out past polls.

    Notices?