- Code: Select all
alec@Kongming:~$ echo '#!md5sum' > md5
alec@Kongming:~$ chmod +x md5
alec@Kongming:~$ ./md5
bash: ./md5: md5sum: bad interpreter: No such file or directory
alec@Kongming:~$
Moderators: phlip, Moderators General, Prelates
alec@Kongming:~$ echo '#!md5sum' > md5
alec@Kongming:~$ chmod +x md5
alec@Kongming:~$ ./md5
bash: ./md5: md5sum: bad interpreter: No such file or directory
alec@Kongming:~$
$ echo '#!'`which md5sum` > md5
$ chmod +x md5
$ ./md5
3190365db110e56a2bc307f24e383685 ./md5
$
roband wrote:Mav is a cow.


<?php
$var='
class Replace {
public function __construct($string) {
$this->source = $string;
}
public function __toString() {
return $this->makeSource();
}
protected function makeSource() {
$body = "<?php\n\n\$var=\'".addcslashes($this->source,"\'")."\';\n\necho eval(\$var);\n";
if (preg_match_all("#\\\$(this->[a-zA-Z][a-zA-Z0-9_]*|[a-zA-Z][a-zA-Z0-9_]*)(\.|\s|\))#", $body, $matches, PREG_SET_ORDER)) {
$vars = array();
foreach ($matches as $match) {
$vars[] = $match[1];
}
array_unique($vars);
foreach ($vars as $var) {
if ($var == "this") continue;
$name = $this->createRandomName();
if (strpos($var, "->") !== false) {
$replace = "\$this->".$name;
} else {
$replace = "\$".$name;
}
$body = str_replace("\$".$var, $replace, $body);
}
}
return $body;
}
protected function createRandomName() {
$returnLen = rand(5, 15);
$chrs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_";
$maxchr = strlen($chrs) - 1;
$return = "";
for ($i = 0; $i < $returnLen; $i++) {
$return .= $chrs[rand(0, $maxchr)];
}
return $return;
}
}
return new Replace($var);';
echo eval($var);
Goplat wrote:Use the absolute path. "#!/usr/bin/md5sum" or wherever it is. (If you don't know, run "which md5sum".)
#!/bin/catDharmaBum wrote:If anyone writes a quine in Brainfuck they win the internet. Shouldn't be impossible considering it's basically a language for writing Turing Machines.
DharmaBum wrote:Another one that would surely yield hilarity is LOLCODE.
#include <stdio.h>
int main()
{ struct { unsigned a:3, b:3, c:2; } n = {0};
do do printf("%hhu\n", *&n);
while(!(n.a-- && !++n.b));
while(++n.c);
return 0; } alias quine='cat'

Pesto wrote:I have not yet had time to start work on porting this to Windows or other operating systems.
#include <stdio.h>
int main()
{ struct { unsigned a:3, b:3, c:2; } n = {0};
do do printf("%hhu\n", *&n);
while(!(n.a-- && !++n.b));
while(++n.c);
return 0; } PM 2Ring wrote:If you think using the repr() function is cheating, feel free to post an alternative.
# Simple Python program to print its own source
def sanitize(s): #turns a string into python input representing the same string
s=list(s)
l=0
while l<len(s):
if s[l]=='\n':
s=s[:l]+['\\','n']+s[l+1:]
l+=2
elif s[l]=='\\':
s=s[:l]+['\\','\\']+s[l+1:]
l+=2
elif s[l]=='\"':
s=s[:l]+['\\','\"']+s[l+1:]
l+=2
else: l+=1
s=reduce(lambda x,y:x+y,s)
return s
s1,s2="# Simple Python program to print its own source\n\ndef sanitize(s): #turns a string into python input representing the same string\n s=list(s)\n l=0\n while l<len(s):\n if s[l]=='\\n':\n s=s[:l]+['\\\\','n']+s[l+1:]\n l+=2\n elif s[l]=='\\\\':\n s=s[:l]+['\\\\','\\\\']+s[l+1:]\n l+=2\n elif s[l]=='\\\"':\n s=s[:l]+['\\\\','\\\"']+s[l+1:]\n l+=2\n else: l+=1\n s=reduce(lambda x,y:x+y,s)\n return s\n\ns1,s2=\"","\"\ns=s1+sanitize(s1)+'\",\"'+sanitize(s2)+s2\nprint s"
s=s1+sanitize(s1)+'","'+sanitize(s2)+s2
print s
0 % cat cheat.py; python cheat.py
print open(__file__).read()
print open(__file__).read()
print (u"*3)[46:-9].replace(chr(117),chr(117)+chr(34)) print (u"*3)[46:-9].replace(chr(117),chr(117)+chr(34))Cosmologicon wrote:We still doing this?
Here's my python one-liner:
- Code: Select all
print (u"*3)[46:-9].replace(chr(117),chr(117)+chr(34)) print (u"*3)[46:-9].replace(chr(117),chr(117)+chr(34))
PM 2Ring wrote:I suspect that skeptical scientist has revived this thread because he's just started learning Python. If so, yay!
Cosmologicon wrote:Here's my python one-liner:
- Code: Select all
print (u"*3)[46:-9].replace(chr(117),chr(117)+chr(34)) print (u"*3)[46:-9].replace(chr(117),chr(117)+chr(34))
All Shadow priest spells that deal Fire damage now appear green.
Big freaky cereal boxes of death.
s = """s =
print s[:4]+chr(34)+chr(34)+chr(34)+s+chr(34)+chr(34)+chr(34)+s[4:]"""
print s[:4]+chr(34)+chr(34)+chr(34)+s+chr(34)+chr(34)+chr(34)+s[4:]Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
Users browsing this forum: Bing [Bot] and 9 guests