Dear experts,
How to use bashlex to separate a bash script file into groups of multi-line commands to execute each group with paramiko.exec_command function?
For example, I want to separate the following bash script into 2 groups (multi-line string), first is "data_mp_info=..." command and second is "if .. fi" command:
data_mp_info=$(df -BG | awk '$6 == "/data"')if [ "$data_mp_info" != "" ]; thendata_mp_size_in_GB=$(echo $data_mp_info | awk '{print $2}' | sed 's/.$//')data_mp_used_in_GB=$(echo $data_mp_info | awk '{print $3}' | sed 's/.$//')data_mp_free_in_GB=$(echo $data_mp_info | awk '{print $4}' | sed 's/.$//')data_mp_used_percent=$(echo $data_mp_info | awk '{print $5}' | sed 's/.$//')elsedata_mp_size_in_GB=-1data_mp_used_in_GB=-1data_mp_free_in_GB=-1data_mp_used_percent=-1fi
Dear experts, How to use bashlex to separate a bash script file into groups of multi-line commands to execute each group with paramiko.exec_command function? For example, I want to separate the following bash script into 2 groups (multi-line string), first is "data_mp_info=..." command and second is "if .. fi" command:
data_mp_info=$(df -BG | awk '$6 == "/data"')
if [ "$data_mp_info" != "" ]; then
data_mp_size_in_GB=$(echo $data_mp_info | awk '{print $2}' | sed 's/.$//')
data_mp_used_in_GB=$(echo $data_mp_info | awk '{print $3}' | sed 's/.$//')
data_mp_free_in_GB=$(echo $data_mp_info | awk '{print $4}' | sed 's/.$//')
data_mp_used_percent=$(echo $data_mp_info | awk '{print $5}' | sed 's/.$//')
else
data_mp_size_in_GB=-1
data_mp_used_in_GB=-1
data_mp_free_in_GB=-1
data_mp_used_percent=-1
fi
Please advise, Thank you, Ha Nguyen