i have a ksh script which internally calls another ksh script.
this inner script has simple commands like shown in the code window.
In the script im trying to do a mv - it fails with arg list too long.
then i try to perform cp and cat - and both are failing with similar error.
:wall:
How is it possible that while trying to move only one file to a different file name - shell is throwing arg list too long error?
Please note - when i run the same command from command prompt it works just fine.
Please suggest/help if someone has seen such a problem before.
thanks.
Script :
echo "Setting outtempfile name."
export outtempfile="${OUTVALIDLIST}""_tmp"
echo "outtempfile=[${outtempfile}]"
/usr/xpg4/bin/rm -f ${outtempfile}
unalias mv
which mv
echo "move command :"
echo "[[[ mv ${OUTVALIDLIST} ${outtempfile} ]]]"
/usr/xpg4/bin/mv ${OUTVALIDLIST} ${outtempfile}
if [ $? -ne 0 ]
then
echo "[WARNING] mv command failed. Source file: [${OUTVALIDLIST}], Destination file: [${outtempfile}]"
echo "Copying content from ${OUTVALIDLIST} to ${outtempfile}"
/usr/xpg4/bin/cp ${OUTVALIDLIST} ${outtempfile}
if [ $? -eq 0 ]
then
echo "[INFO] Successfully Copied content from ${OUTVALIDLIST} to ${outtempfile}"
echo "" > ${OUTVALIDLIST}
else
echo "[INFO] perform change dir"
cd $ABP_MF_ROOT/log
pwd
filename=`basename ${OUTVALIDLIST}`
tmpfilename="${filename}""_tmp"
echo "moving ${filename} to ${tmpfilename}"
mv ${filename} ${tmpfilename}
if [ $? -ne 0 ] ; then
echo "[ERROR] Failed to copy content from ${OUTVALIDLIST} to ${outtempfile}"
return -1
else
echo "[INFO] after perform change dir, mv succeeded"
fi
fi
else
echo "[INFO] mv command succeeded. Source file: [${OUTVALIDLIST}], Destination file: [${outtempfile}]"
fi
The above script fails with this errors:
Setting outtempfile name.
outtempfile=[/work/users........log/VALIDFILELIST_21798_20121108_073435.log_tmp]
/work/users......../script_Sh[22]: /usr/xpg4/bin/rm: arg list too long
/work/users......../script_Sh[25]: /usr/bin/which: arg list too long
move command :
[[[ mv /work/users........log/VALIDFILELIST_21798_20121108_073435.log /work/users........log/VALIDFILELIST_21798_20121108_073435.log_tmp ]]]
/work/users......../script_Sh[30]: /usr/xpg4/bin/mv: arg list too long
[WARNING] mv command failed. Source file: [/work/users........log/VALIDFILELIST_21798_20121108_073435.log], Destination file: [/work/users........log/VALIDFILELIST
_21798_20121108_073435.log_tmp]
Copying content from /work/users........log/VALIDFILELIST_21798_20121108_073435.log to /work/users........log/VALIDFILELIST_21798_20121108_073435.log_tmp
/work/users......../script_Sh[37]: /usr/xpg4/bin/cp: arg list too long
[INFO] perform change dir
/work/users........log
/work/users......../script_Sh[47]: /usr/xpg4/bin/basename: arg list too long
moving to _tmp
/work/users......../script_Sh[50]: /usr/xpg4/bin/mv: arg list too long
[ERROR] Failed to copy content from /work/users........log/VALIDFILELIST_21798_20121108_073435.log to /work/users........log/VALIDFILELIST_21798_20121108_073435.lo
g_tmp
validateScript /work/users......../script_Sh returned failure.