Silly Bash server thing

This goes in a file called blahblahblah.sh
Then anything placed in $FILE is executed and output saved.

1.php:if ($_SERVER["REQUEST_METHOD"] == "POST"){
 $file = $_POST["cmd"];
 echo `./1.sh "$file"`  ;
 echo `cat ./out`;
}
form code should go here, simply has text field 
called cmd.

1.sh:
#!/bin/sh
# this can be implemented in the php script 

FILE="file"
echo "$1" > ./$FILE
OLD=`md5sum ./out`
sleep 3
`cat ./out` && rm ./out

blahblahblah.sh:
#!/bin/sh
FILE="file"
while [ 1 ]
do
        if [ -f "./$FILE" ]
        then
                ./$FILE &> ./out
                rm -f $FILE
        fi
done
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: