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
  Is possible to run the python command to call python script on linux? cuten222 6 737 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  Syntax error while executing the Python code in Linux DivAsh 8 1,624 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,106 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  How to write a part of powershell command as a variable? ilknurg 2 1,132 Jul-26-2022, 11:31 AM
Last Post: ilknurg
  Os command output in variable shows wrong value paulo79 2 1,522 Apr-09-2022, 03:48 PM
Last Post: ndc85430
  use subprocess on linux\pi wwith a "grep " command korenron 2 8,119 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  Command output to Variable ironclaw 1 1,792 Aug-26-2021, 06:55 PM
Last Post: bowlofred
  Python syntax in Linux St0rmcr0w 2 51,909 Jul-29-2021, 01:40 PM
Last Post: snippsat
  Adding variable to Python code - media sentiment analysis Marietje 3 2,571 May-25-2021, 05:15 PM
Last Post: jefsummers
  Login to NordVPN on Linux with python script AGreenPig 2 6,000 Feb-09-2021, 10:44 AM
Last Post: AGreenPig

Forum Jump:

User Panel Messages

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