|
Self-Printing Program
Last post 05-23-2009 12:04 PM by The Wolf. 64 replies.
-
-
asuffield


- Joined on 05-31-2006
- Posts 2,137
|
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)
|
|
-
-
ComputerForumUser


- Joined on 02-15-2007
- Posts 106
|
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?
|
|
-
-
ZiggyFish


- Joined on 03-13-2008
- Posts 29
|
Re: Self-Printing Program
<? echo htmlentities(file_get_contents(__FILE__)); ?>
|
|
-
-
PJH


- Joined on 02-14-2007
- Newcastle, UK
- Posts 3,140
|
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.
3 logicians go into a bar.; the barman says ‘Would you all like a drink?’. The first says 'I’m not sure', the second says 'I’m not sure', and the third says 'Yes'.
|
|
-
-
ZiggyFish


- Joined on 03-13-2008
- Posts 29
|
Re: Self-Printing Program
The OP never mentioned it had to be a quine (it looks like they have names for this (WTF)).
|
|
-
-
Goplat


- Joined on 03-22-2006
- Posts 67
|
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
|
|
-
-
plazmo


- Joined on 12-12-2005
- Posts 100
|
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)
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 1,297
|
Re: Self-Printing Program
fun with data uris: data:text/html,<script>alert(location)</script>
|
|
-
-
rohypnol


- Joined on 11-17-2008
- Romania
- Posts 163
|
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
|
|
-
-
-
fluffy777


- Joined on 08-20-2006
- Santa Cruz
- Posts 37
|
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.
|
|
-
-
m0ffx


- Joined on 08-15-2006
- Posts 602
|
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
|
|
-
-
immibis


- Joined on 01-19-2009
- Posts 139
|
Re: Self-Printing Program
echo "Self"
It's a Self-printing program...
| | |
-
-
-
jh-


- 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>
|
|
-
-
The Wolf


- Joined on 08-12-2006
- Posts 23
|
Re: Self-Printing Program
A bash script: pr<$0
Anyone make it shorter?
|
|
|
|
|