Question

I am running a python script python a.script on a linux box (I know all process information about it from /proc), but I accidentally run 'rm a.script', How can I recovery the script? I found this How do I determine the path to a binary of a process?, but I only found the python interpreter. How about lsof, but I have no idea about what to starts with.

Was it helpful?

Solution

The file itself is gone. You could only recover it by really tricky file system magic. There might be programs for specific file systems (like on DOS) which could recover the file on the disc ... but that is really bad file system trickery.

The other thing is, that the running script is also still in memory. But how could you recover that?? You could make a memory dump of course -- but I guess you only would get precompiled Python code -- and even that will not be easy to find. Get the source back from precompiled Python is not easy. Also you might not get a contiguous block of data, so it is really nearly impossible to get the coding back. At least your comments are really lost. But I would guess, getting back even some shady code without comments will be a task that is more costly than doing the coding again.

So, I regret to tell you: There is no chance, I see.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top