Hello when I am running a script that scp data from a remote server to the local server I capture the scp output .When I vim the file I see that the filename has been truncated Why is this so ?
bondrcpt_CEP_900_2303_2019_M04_BOND_REC_20181 0% 0 0.0KB/s --:-- ETAbondrcpt_CEP_900_2303_2019_M04_BOND_REC_20181 100% 84 1.6KB/s 00:00 bondrfnd_CEP_900_2303_2019_M06_BOND_REC_20181 0% 0 0.0KB/s --:-- ETAbondrfnd_CEP_900_2303_2019_M06_BOND_REC_20181 100% 1372 60.7KB/s 00:00 bondrcpt_CEP_900_2303_2019_M04_BOND_REC_20181 0% 0 0.0KB/s --:-- ETAbondrcpt_CEP_900_2303_2019_M04_BOND_REC_20181 100% 84 3.8KB/s 00:00
The proper file names are bondrcpt_CEP_900_2303_2019_M04_BOND_REC_20181005_20230816_180040.TXT bondrfnd_CEP_900_2303_2019_M06_BOND_REC_20181231_20230814_180541.TXT
The code is the following in bash script It goes through the array and and scp the required Files
for FILE in "${FILEMASKS[@]}"; do
script -q -c "scp ${USER}@${SERVER}:${SOURCE}/${FILE}* ${DEST}" >> ${TRX_LOG}
#need to REMOVE ^M from the log
sed -i -e 's/\r//g' ${TRX_LOG}
done
The scp
utility is intended for someone to use interactively. The scp
output that you're talking about is referred to as the "progress meter", and scp formats it to fit on one line of the terminal. While running, scp gets the terminal's width in characters (using a value of 80 if it can't get the width). It reserves 36 characters for the file size, amount transferred, and the running time of the transfer. The rest of the line is used for the filename. If the filename is too long to fit in the space, it's truncated.
Your example filenames are 67 and 68 characters long. It seems scp would need a terminal that's 104 characters or more wide to display the filenames without truncating them.
If you're running this script in a terminal window, you could try making the terminal window wider. Alternately, you could try setting the terminal width to something wider in the script:
script -q -c "stty cols 150; scp ${USER}@${SERVER}:${SOURCE}/${FILE}* ...
This probably won't work (and will produce an error) if the command isn't running in a TTY.