Jun-24-2024, 09:06 AM
(This post was last modified: Jun-24-2024, 09:06 AM by robertkwild.)
(Jun-22-2024, 11:58 AM)deanhystad Wrote: Read the documentation. You need to separate the arguments from the command, not have all in one string. You can do it the way you have, but then you need shell = True.
\ is used to start escape sequences for including non-visible characters in a string. Like \n for a new line. Use a raw string or \\ to make them just a backslash
ok done a test and it works so when i get home tonight i will try it in my script
import subprocess subprocess.run('C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe ipconfig', shell=True)ok ive put this in my script but what line do i put it in my script as its not working as expected, i only want it to run ie show the ipconfig details when they hit the submit button and all the validations are good
@app.route('/password', methods=['GET', 'POST']) def password(): form = PasswordForm() if request.method == 'POST' and form.validate(): return '<h1>The username is {}. The old password is {}. the new password is {}. changing for domain {}'.format(form.un.data, form.op.data, form.cnp.data, form.dom.data) return subprocess.run('C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe ipconfig', shell=True) return render_template('password.html', form=form) if __name__ == '__main__': app.run(debug=True)