Category Archives: Script

sample python script

You can use following python script to check whether python is running correctly on your server.

1) Create a script with extension py say sample.py and add following code to it.

 

#!/usr/bin/python

import cgi

print("<Content-Type: text/html\n")

print("ok")

 

2) Access script in the browser.

http://www.your-site-name.com/sample.py

3) Output of this script should be “OK” If you see complete code in the browser then this indicate that code is not being compiled by python. to fix this create a .htaccess file and add following code.

AddHandler cgi-script .cgi .py .pl

 

 


contact@webhostingsupport.info

Post to Twitter

changing all file and directory permissions.at same time

1) Following command will search for all the directory in the current directory and change the permission.

find -type d -exec chmod 755 ‘{}’ \;

2) Following command will search for all the files in the current directory and change the permission.

find -type f -exec chmod 644 ‘{}’ \


contact@webhostingsupport.info

Post to Twitter

Test cgi script

If for some reason your cgi script is not working, then you can create a test cgi script to check if it works.

If test cgi script is also not working then there seems to be some server configuration problem.

Before creating cgi scrip check for the perl path on server. You can check the per path on server by ssh to server adn execute following commend.

[root@ Server~]# which perl
/usr/local/bin/perl

1) Under your document root look for directory cgi-bin and create your test cgi script under it

[root@ Server~]#vi test.cgi

2) Now paste following code in to the file

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

print <<END_HTML;
<html>
<head></head>
<body>Hello, World!</body>
</html>
END_HTML

3) change permission for the file to 755

Thats all….



contact@webhostingsupport.info

Post to Twitter