sudoPassword = 'mypass' command = 'mount -t vboxsf myfolder /home/myuser/myfolder' p = os.system('echo %s|sudo -S %s' % (sudoPassword, command))
Try this and let me know if it works. 🙂
And this one:
os.popen("sudo -S %s"%(command), 'w').write('mypass')
Related Posts:
- python getoutput() equivalent in subprocess
- How to execute a program or call a system command?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- Is there a Python equivalent to the ‘which’ command
- Running shell command and capturing the output
- Shell Script: Execute a python program from within a shell script
- Meaning of “! -S” in shell script
- “No such file or directory” but it exists
- How do I split a string on a delimiter in Bash?
- Ubuntu says “bash: ./program Permission denied” [closed]
- How do I copy a folder from remote to local using scp?
- How to concatenate string variables in Bash
- -bash: syntax error near unexpected token `)’
- An example of how to use getopts in bash
- OSError: [WinError 193] %1 is not a valid Win32 application
- How to delete from a text file, all lines that contain a specific string?
- How to mkdir only if a directory does not already exist?
- OSError: [Errno 8] Exec format error
- How do I iterate over a range of numbers defined by variables in Bash?
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- How to set ssh timeout?
- commands not found on zsh
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- subprocess.check_output return code
- sudo: apt-get: command not found
- How do I iterate over a range of numbers defined by variables in Bash?
- How to mkdir only if a directory does not already exist?
- Using find to locate files that match one of multiple patterns
- “unary operator expected” error in Bash if condition
- takes 1 positional argument but 2 were given
- What does “-ne” mean in bash?
- How to generate random number in Bash?
- How to check if a variable is set in Bash?
- Who can access a file with octal permissions “000” on Linux/UNIX?
- How can I compare numbers in Bash?
- What does the line “#!/bin/sh” mean in a UNIX shell script?
- Open and write data to text file using Bash?
- Python error – IDLE’s subprocess didn’t make connection. Either IDLE can’t start or personal firewall software is blocking connection
- How do I set a variable to the output of a command in Bash?
- What is the $? (dollar question mark) variable in shell scripting?
- Is there a TRY CATCH command in Bash
- What can lead to “IOError: [Errno 9] Bad file descriptor” during os.system()?
- dquote> result of a execution a program in linux shell
- how to fix the issue “Command /bin/sh failed with exit code 1” in iphone
- Run a string as a command within a Bash script
- Python Subprocess: Too Many Open Files
- conditional binary operator expected in shell script
- Is there any simple way to benchmark Python script?
- Block Comments in a Shell Script
- how to check which version of nltk, scikit learn installed?
- How to get a shell environment variable in a makefile?
- What are the uses of the exec command in shell scripts?
- using rot13 and tr command for having an encrypted email address
- sed whole word search and replace
- What’s the difference betwen the single dash and double dash flags on shell commands?
- How to let ‘cp’ command don’t fire an error when source file does not exist?
- How do I update\upgrade pip itself from inside my virtual environment?
- What does the “yield” keyword do?
- Renaming column names in Pandas
- Does Python have a string ‘contains’ substring method?
- Behaviour of increment and decrement operators in Python
- Is there a “not equal” operator in Python?
- IndexError: list index out of range and python
- `from … import` vs `import .` [duplicate]
- How can I safely create a nested directory in Python?
- How to read a text file into a string variable and strip newlines?
- ln (Natural Log) in Python
- How do I select rows from a DataFrame based on column values?
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
- How can I convert a character to a integer in Python, and viceversa?
- Python -How to solve OSError: [Errno 22] Invalid argument
- ‘End of statement expected’ in pycharm
- How to import files in python using sys.path.append?
- Tensorflow: why ‘pip uninstall tensorflow’ cannot find tensorflow
- JSON to pandas DataFrame
- Convert decimal to binary in python
- How to remove specific elements in a numpy array
- Converting between datetime and Pandas Timestamp objects
- Pandas long to wide reshape, by two variables
- how to create a list of lists
- Python – ‘ascii’ codec can’t decode byte
- Python assigning multiple variables to same value? list behavior
- IDLE’s subprocess didn’t make a connection. Either IDLE can’t start or personal firewall software is blocking the connection
- How to update a plot in matplotlib?
- ImportError: No module named MySQLdb
- How to start from second index for for-loop
- What does this Django regular expression mean? `?P`
- Strange error about invalid syntax
- ‘virtualenv’ is not recognized as an internal or external command, operable program or batch file
- Python Coin Toss
- Should Python class filenames also be camelCased?
- gunicorn.errors.HaltServer:
django - What is a clean, Pythonic way to have multiple constructors in Python?
- Python Login Script; Usernames and Passwords in a separate file
- Python 2.7 mixing iteration and read methods would lose data
- Conditional indexing with Numpy ndarray
- How to run command as user who has /usr/sbin/nologin as Shell?
- Update media item using wordpress rest api in python