Need some help with python coding
I'm currently writing a prank program in python for linux.
The main idea is that the program should start up by itself, asks the user to press enter, claims it is destroying the operating system( when it's not ), and shuts it down.
I found several issues concerning my program.
a) the user has to run the program itself, in this case they have to go to BASH and type "python program.py". I want my program to be a self - executing program.
b) This is concerning the shutdown part as a user has to be root. so i tried to do something like os.system("sudo su") (i'm running ubuntu) but when i tested it, it simply switches to root and doesn't begin the shutdown, i exited back to a normal user shell, but then it says: shutdown:user must be root.
so i tried os.system("sudo su && shutdown -r -h 5"), but it seems to yield the same result.
so i'm thinking of a way for the user to simply switch to root, and then automatically starts shutting down without the user entering the shutdown command.
Does anyone here know what i should add on my code, maybe along with some code and websites.
I'm going to work on the windows version as soon i manage to finish this one first.
fuser wrote:
a) the user has to run the program itself, in this case they have to go to BASH and type "python program.py". I want my program to be a self - executing program.
autorun? That's easy to google…
b) This is concerning the shutdown part as a user has to be root. so i tried to do something like os.system("sudo su") (i'm running ubuntu) but when i tested it, it simply switches to root and doesn't begin the shutdown, i exited back to a normal user shell, but then it says: shutdown:user must be root.
They'd still have to enter their password for the sudo command, right?
so i tried os.system("sudo su && shutdown -r -h 5"), but it seems to yield the same result.
I think you should do 2 commands for this…though it might not be necessary, idk, but it might..
os.system("sudo su") os.system("shutdown -r -h 5")
I'm going to work on the windows version as soon i manage to finish this one first.
That will be really easy…
"Everything in this [post] could be wrong." – Modded Illusions quote :)
yeah. the user has to enter thier own password. ( I know cuz i tested it several times)
The main idea is that, well, the program asks the user to enter the root password, after the password is entered and the user changes to root, the program would then automatically shuts down the computer without any user input
The main problem with this app is that right now, it simply switches to root and that's it.
as far as getting the program to auto run, just make it a scheduled task. i dont use linux, but i'm sure there must be an easy way to do that. in windows it's in the control panel.
as far as writing the windows version, i'm pretty sure the built in shutdown command should work fine, but if it doesnt, i have a nice batch file i could give you that'll do the job.
for windows: have it edit the registry and make itself autostart at runtime OR put it in the scheduled tasks There is a command line way for both (i've done it)
for linux: put it in the start up OR put it into cron again both are command line
as for the shutdown, you may be able to do it with just os.system(sudo shutdown) but that will require a password. os.system(init 0) may work without a password tho, tbh, in not sure tho