'The If else statement for Python's subprocess doesn't seem to work
I created a simple script to locate a user on the local machine. Despite entering any characters in the input box, the answer remains the same. I am grateful for any assistance.
#!/usr/bin/python
import subprocess
user = input("Enter username : ")
result = subprocess.getoutput("getent passwd" + user)
if result:
print(("found "+user+" user in this system."))
else:
print((""+user+" is not found..."))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
