The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

Self-Printing Program

Last post 05-23-2009 12:04 PM by The Wolf. 64 replies.
Page 2 of 2 (65 items) < Previous 1 2
Sort Posts: Previous Next
  • 02-13-2008 4:32 PM In reply to

    Re: Self-Printing Program

    Spectre:
    Tcl actually, but I guess Expect would run it too.

    (They're basically the same thing, expect is just the tcl interpreter with a few more functions added)

  • 03-12-2008 7:46 PM In reply to

    Re: Self-Printing Program

    All one line:

    <?php $str = '<?php $str = \'X\'; echo substr_replace($str, addslashes($str), 14, 1); ?>'; echo substr_replace($str, addslashes($str), 14, 1); ?>

    Who is Mark Read, and why is he in all my email?
  • 03-13-2008 4:42 AM In reply to

    Re: Self-Printing Program

    <?
        echo htmlentities(file_get_contents(__FILE__));
    ?>


  • 03-13-2008 5:52 AM In reply to

    • PJH
    • Top 10 Contributor
    • Joined on 02-14-2007
    • Newcastle, UK
    • Posts 3,916

    Re: Self-Printing Program

    ZiggyFish:
    <?
        echo htmlentities(file_get_contents(__FILE__));
    ?>
    It might be self-printing, but that certainly ain't a quine, and wouldn't qualify as such.

    "Because you watched 'The Very Hungry Caterpillar,' we recommend 'The Human Centipede.'"
    --
    UED - Countryside: To kill Piers Morgan
  • Parp!
  • 03-13-2008 6:26 AM In reply to

    Re: Self-Printing Program

    The OP never mentioned it had to be a quine (it looks like they have names for this (WTF)). 



  • 03-14-2008 6:19 PM In reply to

    Re: Self-Printing Program

    A BASIC quine without using LIST:

    1 READ D$,S$:PRINT S$:PRINT D$;SPC(1);D$;MKI$(8748);S$
    2 DATA 2 DATA,"1 READ D$,S$:PRINT S$:PRINT D$;SPC(1);D$;MKI$(8748);S$

    An mIRC quine:

    //var %q $(| echo //var % $+ q $!( $+ %q $+ ,0) %q,0) | echo //var % $+ q $!( $+ %q $+ ,0) %q

  • 03-17-2008 9:34 AM In reply to

    Re: Self-Printing Program

    heres my first attempt at a real quine.

    sql proc:

    create proc q as declare @d varchar(500) set @d = 'create proc q as declare @d varchar(500) set @d = xyx select replace(replace(@d,char(120),char(39)),char(121),@d)' select replace(replace(@d,char(120),char(39)),char(121),@d) 

  • 03-17-2008 10:18 AM In reply to

    Re: Self-Printing Program

    fun with data uris:

    data:text/html,<script>alert(location)</script> 

  • 12-11-2008 9:36 AM In reply to

    Re: Self-Printing Program

    mfah:

     

    AbbydonKrafts:

    gremlin:

     No, that doesn't print out its source code.
     



    Sure it does. The only time it doesn't is if ECHO OFF was used before running it. Sample output of "TESTBAT.BAT" that only contains the statement "REM":


    C:\>testbat

    C:\>REM

    C:\>echo off
    testbat
    echo on

    C:\>

    @echo off

    type printme.bat

     

     

     

    @type a.bat

    and I love prepositions or
  • 12-12-2008 6:50 AM In reply to

    Re: Self-Printing Program

     XQuery:

    1


  • 12-29-2008 11:15 PM In reply to

    Re: Self-Printing Program

    Worf:
    A recent (a couple years ago or so) back, the IOCCC had such an entry. It started out formatted as a Japanese character. Compile, run, outputs source code in the form of another Japanese character. Compile/run, you get a third, and so on for at least 6 times, at which point, you ended up with the beginning character.

    yeah, look for dhyang, I forget the year, and it's 4 characters repeating.

  • 12-30-2008 2:43 PM In reply to

    Re: Self-Printing Program

    Well, for interpreted languages. For compiled languages would be slightly different - a file that generates a compiler error matching the file. Rather non-portable. This works for gcc 4.2.4:

    /usr/bin/ld:errorquine: file format not recognized; treating as linker script
    /usr/bin/ld:errorquine:2: syntax error
    collect2: ld returned 1 exit status

    TRWTF is Community Server
  • 01-19-2009 11:07 PM In reply to

    Re: Self-Printing Program

    echo "Self"

    It's a Self-printing program...


  • Wed, Dec 15 2010 6:34 AM

    • Username
    • Top 10 Contributor
    • Joined on Mon, Jan -1 3141.5926535
    • Posts -70 trillion
    Hey PJH, make your own signature guy instead of copying mine (complete with bugs)
  • 01-21-2009 6:07 PM In reply to

    • jh-
    • Not Ranked
    • Joined on 01-21-2009
    • Posts 1

    Re: Self-Printing Program

    asuffield:
    This stopped being difficult when languages gained self-referential capabilities
    In Perl:
    seek DATA,0,0;print while <DATA>
    __END__
    
    Shorter one: open F,$0;print while<F>
  • 05-23-2009 12:04 PM In reply to

    Re: Self-Printing Program

    A bash script: pr<$0 Anyone make it shorter?
Page 2 of 2 (65 items) < Previous 1 2
Powered by Community Server (Non-Commercial Edition), by Telligent Systems