I have a text file say 1.txt from where I am fetching some keywords like "sent", "inbox", "outbox" etc. for it to be replaced in a command line.
Below is how the command line looks:
curl -H "pqr: thisisalsolink" -X PUT "https://example.com/artifactory/xyz/mainlist/oldtext.txt" -T newtext.txt
I am trying to replace the "mainlist" with the data i fetched from 1.txt file, e.g.
curl -H "pqr: thisisalsolink" -X PUT "https://example.com/artifactory/xyz/sent/oldtext.txt" -T newtext.txt curl -H "pqr: thisisalsolink" -X PUT "https://example.com/artifactory/xyz/inbox/oldtext.txt" -T newtext.txt
I have tried by adding this by creating two strings and concatenating it but looks like I am going wrong.
ltppath=r"/home/Desktop/1.txt"
with open((ltppath),'r') as fh:
ls=fh.readlines()
for line in ls:
string1="curl -H "pqr: thisisalsolink" -X PUT "https://example.com/artifactory/xyz/"+line.strip()
string2="/oldtext.txt" -T newtext.txt"
conc=string1+string2
cmd=os.system(conc)
Can someone please help me in finding solution for this i am very new to python.