Python Forum
How to use a variable in linux command in python code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use a variable in linux command in python code?
#1
I have a python code. In my code I run this commands via os.system. How can i give sAMAccountName as a parameter?

I have a variable which is name. It can change in every search. I want to write name instead of the sAMAccount, and command will run according to it.

ldapsearch -x -H "ldap://192.168.1.240:368" -D "[email protected]" -w "foo" -b "dc=my,dc=server" '(sAMAccountName=user1)'
Reply
#2
Do you un
Coricoco_fr likes this post
Reply
#3
Do you understand f-strings, or at least string concatenation?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I trying to automate the Variable Logon button using the python code but I couldn't surendrasamudrala 0 286 Mar-07-2025, 05:02 AM
Last Post: surendrasamudrala
  [SOLVED] [Linux] Run Python script through cron? Winfried 2 1,233 Oct-19-2024, 06:29 PM
Last Post: Winfried
  Linux, Python, C ++, Brain2 and errors. PiotrBujakowski 0 991 Jun-24-2024, 03:41 PM
Last Post: PiotrBujakowski
  Is possible to run the python command to call python script on linux? cuten222 6 2,393 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  Syntax error while executing the Python code in Linux DivAsh 8 5,129 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 2,145 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  How to write a part of powershell command as a variable? ilknurg 2 1,920 Jul-26-2022, 11:31 AM
Last Post: ilknurg
  Os command output in variable shows wrong value paulo79 2 2,323 Apr-09-2022, 03:48 PM
Last Post: ndc85430
  use subprocess on linux\pi wwith a "grep " command korenron 2 11,259 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  Command output to Variable ironclaw 1 3,821 Aug-26-2021, 06:55 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020