nighter33
asked on
Problem passing file name with spaces to shell script
A part of my python script calls a shell script (Rsyncc.sh) and passes variables.
Problem is with var3 which is a file name. If it contains spaces, Rsyncc.sh doesn't get the entire string.
var3 = "/app/interface/exports/TE ST5191 326150.txt"
My question is how to send var3 - imbedded spaces and all?
bashcall(var,var1,var2,var 3):
irtn = os.system("./Rsyncc.sh %s %s %s %s " % (var,var1,var2,var3))
This is the code from rsyncc.sh. sfile accepts parameter #4, the file name(sfile).
#!/bin/bash
clear
# Variables below
remotehost=$1
rsyncmodule=$2
dest=$2
sfile=$4
rsync -avz -e "ssh -p 22 -i /home/testusr/.ssh/key1 " $sfile rsyncadmin@$remotehost:$de st
Problem is with var3 which is a file name. If it contains spaces, Rsyncc.sh doesn't get the entire string.
var3 = "/app/interface/exports/TE
My question is how to send var3 - imbedded spaces and all?
bashcall(var,var1,var2,var
irtn = os.system("./Rsyncc.sh %s %s %s %s " % (var,var1,var2,var3))
This is the code from rsyncc.sh. sfile accepts parameter #4, the file name(sfile).
#!/bin/bash
clear
# Variables below
remotehost=$1
rsyncmodule=$2
dest=$2
sfile=$4
rsync -avz -e "ssh -p 22 -i /home/testusr/.ssh/key1 " $sfile rsyncadmin@$remotehost:$de
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the suggestions but same error -only passes the first part of the file name up to the first space in both cases..
Did you make the changes I suggested to the bash code? They're required, regardless of what you're doing with the Python code!
ASKER
My error. I made both changes and it works!
Thank you very much.
Thank you very much.
ASKER
Response was very quick.
If you made both changes, why did you accept only one answer?
I agree - wmp and I gave half the answer each!
ASKER
Sorry, new to this. Can I correct?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
bashcall(var,var1,var2,"va
irtn = os.system("./Rsyncc.sh %s %s %s %s " % (var,var1,var2,"var3"))
Or does the above keep Python from interpreting "var3" as a variable name? Sorry for the stupid suggestion then!