{"id":663,"date":"2018-03-27T13:07:06","date_gmt":"2018-03-27T13:07:06","guid":{"rendered":"https:\/\/hosting-marketers.com\/news\/?p=663"},"modified":"2018-03-27T13:07:06","modified_gmt":"2018-03-27T13:07:06","slug":"how-to-run-python-scripts","status":"publish","type":"post","link":"https:\/\/hosting-marketers.com\/news\/2018\/03\/27\/how-to-run-python-scripts\/","title":{"rendered":"How to run Python scripts"},"content":{"rendered":"<h1 class=\"kb-article-title\">How to run Python scripts<\/h1>\n<p>If you wish to run Python scripts in your hosting account, you can create and edit them in two ways: either in cPanel or via SSH.<\/p>\n<p><b>To create and edit Python script in cPanel use the following steps:\u00c2\u00a0<\/b><\/p>\n<p>1. Log in to your\u00c2\u00a0<b>cPanel<\/b>:<br \/>\n2. Go to section<b>\u00c2\u00a0Files<\/b>\u00c2\u00a0&gt;\u00c2\u00a0<b>File Manager<\/b>:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"kb-image\" src=\"https:\/\/i0.wp.com\/namecheap.simplekb.com\/\/SiteContents\/2-7C22D5236A4543EB827F3BD8936E153E\/media\/pytonscripts1.png?w=640&#038;ssl=1\" \/><\/p>\n<p>3. You can choose whether you want to run the script in the cgi-bin folder or outside of it.<\/p>\n<p><b>The cgi-bin\u00c2\u00a0<\/b>folder contains executable\u00c2\u00a0<b>CGI<\/b>\u00c2\u00a0scripts. If the file should be placed out of the cgi-bin folder,<b>\u00c2\u00a0.htaccess<\/b>\u00c2\u00a0should be created additionally.<\/p>\n<p>4. In order to run the Python script in the cgi-bin folder follow the steps:<\/p>\n<ul>\n<li>Go to the\u00c2\u00a0<b>cgi-bin<\/b>\u00c2\u00a0folder<\/li>\n<li>Create a file with a<i>\u00c2\u00a0.py<\/i>\u00c2\u00a0extension, for example\u00c2\u00a0<i>nctest.py<\/i>\u00c2\u00a0in the\u00c2\u00a0<i>\/home\/cPuser\/public_html\/cgi-bin<\/i>\u00c2\u00a0directory (where cPuser is your actual cPanel username).<\/li>\n<\/ul>\n<p>5. In order to create the file, click<b>\u00c2\u00a0New File\u00c2\u00a0<\/b>&gt; specify the name of the file with the required extension and click\u00c2\u00a0<b>Create New File<\/b>:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"kb-image\" src=\"https:\/\/i0.wp.com\/namecheap.simplekb.com\/\/SiteContents\/2-7C22D5236A4543EB827F3BD8936E153E\/media\/pytonscripts2.png?w=640&#038;ssl=1\" \/><\/p>\n<p>6. Change the permission of the file to\u00c2\u00a0<b>0755<\/b><\/p>\n<p><b>NOTE:<\/b>\u00c2\u00a0Files are created with default permissions<b>\u00c2\u00a00644<\/b>. The\u00c2\u00a0<i>.py<\/i>\u00c2\u00a0file will become executable when the permissions are changed to\u00c2\u00a0<b>0755<\/b>.<\/p>\n<p>7. In order to change the permissions of the file you need to\u00c2\u00a0<b>select the file\u00c2\u00a0<\/b>&gt; click\u00c2\u00a0<b>Change Permissions<\/b>\u00c2\u00a0&gt;\u00c2\u00a0<b>Mark Execute for User, Group, World<\/b>\u00c2\u00a0columns and click\u00c2\u00a0<b>Change Permissions<\/b>:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"kb-image\" src=\"https:\/\/i0.wp.com\/namecheap.simplekb.com\/\/SiteContents\/2-7C22D5236A4543EB827F3BD8936E153E\/media\/pytonscripts3.png?w=640&#038;ssl=1\" \/><\/p>\n<p>8. Open the file, click\u00c2\u00a0<b>Edit\u00c2\u00a0<\/b>and add the code.<\/p>\n<p>We will add the following script for testing purposes:<\/p>\n<p><i>#!\/usr\/bin\/python<\/p>\n<p>print &#8220;Content-type: text\/html\\n\\n&#8221;<br \/>\nprint &#8220;How to run Python scripts in cPanel&#8221;<br \/>\n<\/i><br \/>\n<b>NOTE:\u00c2\u00a0<\/b>The file should start with the path to the Python scripts that is\u00c2\u00a0<i>\/usr\/bin\/python<\/i>\u00c2\u00a0on our servers, but you can run the\u00c2\u00a0<i>whereis python<\/i>command via SSH to check the directory.<\/p>\n<p>Now the script should work using\u00c2\u00a0<i>http:\/\/domain.com\/cgi-bin\/nctest.py<\/p>\n<p><\/i>If you would like to run the Python file not in the cgi-bin folder (in public_html or any other directory), it is necessary to add the following code to the<i>\u00c2\u00a0.htaccess<\/i>\u00c2\u00a0file in the same directory where the Python script is placed:<\/p>\n<p><i>Options +ExecCGI<br \/>\nAddHandler cgi-script .py\u00c2\u00a0<\/i><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to run Python scripts If you wish to run Python scripts in your hosting account, you can create and edit them in two ways: either in cPanel or via SSH. To create and edit Python script in cPanel use the following steps:\u00c2\u00a0 1. Log in to your\u00c2\u00a0cPanel: 2. Go to section\u00c2\u00a0Files\u00c2\u00a0&gt;\u00c2\u00a0File Manager: 3. You [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[168],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-hosting-marketers-news","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p9Yxzd-aH","jetpack-related-posts":[{"id":138,"url":"https:\/\/hosting-marketers.com\/news\/2009\/11\/19\/register_globals-on-servers-with-suexec\/","url_meta":{"origin":663,"position":0},"title":"register_globals on servers with SuExec","author":"Admin","date":"November 19, 2009","format":false,"excerpt":"First of all allowing register_globals on, on a server is real stupid, it is a security risk that no hosting company should accept, but sometimes for old scripts it is necessary to have it on, in this case should be enabled on the customer account on the .htaccess file or\u2026","rel":"","context":"In &quot;Hosting Marketers News&quot;","block_context":{"text":"Hosting Marketers News","link":"https:\/\/hosting-marketers.com\/news\/category\/hosting-marketers-news\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1323,"url":"https:\/\/hosting-marketers.com\/news\/2024\/05\/28\/effortlessly-separate-web-and-email-hosting-a-step-by-step-guide-to-setting-up-a-dedicated-mail-server-with-whm-cpanel\/","url_meta":{"origin":663,"position":1},"title":"Effortlessly Separate Web and Email Hosting: A Step-by-Step Guide to Setting Up a Dedicated Mail Server with WHM\/cPanel","author":"Admin","date":"May 28, 2024","format":false,"excerpt":"[et_pb_section fb_built=\"1\" _builder_version=\"4.23\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_row _builder_version=\"4.23\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_column type=\"4_4\" _builder_version=\"4.23\" _module_preset=\"default\" global_colors_info=\"{}\"][et_pb_text _builder_version=\"4.24.2\" _module_preset=\"default\" global_colors_info=\"{}\"]In today\u2019s digital landscape, efficiently managing your web and email hosting can significantly enhance your server performance and security. If you\u2019re using WHM\/cPanel and looking to streamline your hosting setup, separating your web and email hosting\u2026","rel":"","context":"In &quot;email&quot;","block_context":{"text":"email","link":"https:\/\/hosting-marketers.com\/news\/category\/email\/"},"img":{"alt_text":"EmailServer","src":"https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2024\/05\/DALL%C2%B7E-2024-05-28-07.48.22-A-sleek-modern-data-center-with-two-distinct-server-racks-labeled-Web-Hosting-and-Email-Hosting.-The-Web-Hosting-rack-is-connected-to-a-cPanel-.webp?fit=1200%2C686&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2024\/05\/DALL%C2%B7E-2024-05-28-07.48.22-A-sleek-modern-data-center-with-two-distinct-server-racks-labeled-Web-Hosting-and-Email-Hosting.-The-Web-Hosting-rack-is-connected-to-a-cPanel-.webp?fit=1200%2C686&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2024\/05\/DALL%C2%B7E-2024-05-28-07.48.22-A-sleek-modern-data-center-with-two-distinct-server-racks-labeled-Web-Hosting-and-Email-Hosting.-The-Web-Hosting-rack-is-connected-to-a-cPanel-.webp?fit=1200%2C686&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2024\/05\/DALL%C2%B7E-2024-05-28-07.48.22-A-sleek-modern-data-center-with-two-distinct-server-racks-labeled-Web-Hosting-and-Email-Hosting.-The-Web-Hosting-rack-is-connected-to-a-cPanel-.webp?fit=1200%2C686&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2024\/05\/DALL%C2%B7E-2024-05-28-07.48.22-A-sleek-modern-data-center-with-two-distinct-server-racks-labeled-Web-Hosting-and-Email-Hosting.-The-Web-Hosting-rack-is-connected-to-a-cPanel-.webp?fit=1200%2C686&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":32,"url":"https:\/\/hosting-marketers.com\/news\/2005\/03\/27\/how-does-a-web-server-work\/","url_meta":{"origin":663,"position":2},"title":"How does a web server work?","author":"Hosting Marketers","date":"March 27, 2005","format":false,"excerpt":"Check Hosting Marketers it is a hosting company which offers, all that can be expected from a high quality hosting company, but with the cheapest prices on the net. When you are going to order cheap web hosting, it will be a good idea to know more about how does\u2026","rel":"","context":"In &quot;Hosting Marketers News&quot;","block_context":{"text":"Hosting Marketers News","link":"https:\/\/hosting-marketers.com\/news\/category\/hosting-marketers-news\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":184,"url":"https:\/\/hosting-marketers.com\/news\/2010\/11\/02\/what-to-do-when-your-site-is-hacked-or-when-you-arrive-at-your-site-you-this-warning-reported-attack-page\/","url_meta":{"origin":663,"position":3},"title":"what to do when your site is hacked or when you arrive at your site you see this warning: Reported Attack Page!","author":"Admin","date":"November 2, 2010","format":false,"excerpt":"What to look for The three most common forms of badware that StopBadware sees on compromised sites are: 1. Malicious scripts 2. .htaccess redirects 3. Hidden iframes Malicious scripts Malicious scripts are often used to redirect site visitors to a different website and\/or load badware from another source. These scripts\u2026","rel":"","context":"In &quot;Reported Attack Page!&quot;","block_context":{"text":"Reported Attack Page!","link":"https:\/\/hosting-marketers.com\/news\/category\/reported-attack-page\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":59,"url":"https:\/\/hosting-marketers.com\/news\/2008\/04\/07\/installing-phpmotion-v2-rc1\/","url_meta":{"origin":663,"position":4},"title":"Installing PHPmotion V3","author":"Admin","date":"April 7, 2008","format":false,"excerpt":"The following instructions only apply to Version 3 of PHPmotion. For V1 please refer to the instructions provided inside the downloaded zip file Download the the zipped file from PHPmotion, the version for PHP 5.x is the one which will work on our servers: http:\/\/downloads.phpmotion.com\/V3.5\/php5.2.x\/phpmotion.zip Before you begin Ensure that\u2026","rel":"","context":"In &quot;Hosting Marketers News&quot;","block_context":{"text":"Hosting Marketers News","link":"https:\/\/hosting-marketers.com\/news\/category\/hosting-marketers-news\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1353,"url":"https:\/\/hosting-marketers.com\/news\/2025\/02\/24\/how-to-secure-your-wordpress-and-laravel-sites-on-a-hosting-marketers-shared-accounts\/","url_meta":{"origin":663,"position":5},"title":"How to Secure Your WordPress and Laravel Sites on a Hosting Marketers Shared Accounts","author":"Admin","date":"February 24, 2025","format":false,"excerpt":"Website security is critical for protecting your data, preventing hacks, and ensuring your site runs smoothly. While your hosting provider has CSF Firewall to protect the server from external threats, securing your WordPress or Laravel site is your responsibility. Many hacks happen because of poor security practices\u2014such as outdated plugins,\u2026","rel":"","context":"In &quot;security&quot;","block_context":{"text":"security","link":"https:\/\/hosting-marketers.com\/news\/category\/security\/"},"img":{"alt_text":"How to Secure Your WordPress and Laravel Sites on a Hosting Server with CSF Firewall","src":"https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2025\/02\/security.jpg?fit=1024%2C1024&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2025\/02\/security.jpg?fit=1024%2C1024&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2025\/02\/security.jpg?fit=1024%2C1024&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/hosting-marketers.com\/news\/wp-content\/uploads\/2025\/02\/security.jpg?fit=1024%2C1024&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":1,"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":664,"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/posts\/663\/revisions\/664"}],"wp:attachment":[{"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hosting-marketers.com\/news\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}