I'm running this code for trying to ping a server on pycharm:
import subprocess as sp
ip = "216.52.241.254"
status,result = sp.getstatusoutput("ping -c1 -w2 " + ip)
if status == 0:
print("System " + ip + " is UP !")
else:
print("System " + ip + " is DOWN !")
print(result)
However the print(result)
line always prints "Access denied. Option -c1 requires administrative privileges."
. I've tried running pycharm as admin but it doesn't have any affect. How can I give admin privileges to the file?
Startup pycharm as Administrator then all scripts will be ran as administrator.
From Windows start menu right click the Pycharm shortcut and select 'Run as administrator.' Optionally create a short and change the options to always Run as Administrator under the "Compatibility" tab.
Simply run the PyCharm shortcut as administrator, and then PyCharm terminal will run with admin privileges.
See these images for referral,
For Desktop PyCharm Shortcut
For Start menu search of PyCharm Shortcut
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With