I am trying to write a script file via a Python script
For that I have defined a function to open, write & close file
def funcToCreateScript(filename,filecontent)
I have another function, where I am calling funcToCreateScript and am trying to pass it shell script content through a variable. The problem is when I format the text as below
def createfile():
var = """#!/bin/sh
echo ${test}
"""
funcToCreateScript(filename,var)
I get the output of script as -
#!/bin/sh
echo ${test}
So, its taking the function's indentation and writing it accordingly. Is there a way to format it so that it will look like
#!/bin/sh
echo ${test}
e.g. -
def main():
var = """
#!/bin/sh
echo ${test}
"""
print var
main()
> test.py
#!/bin/sh
echo ${test}