Originally Posted by manju98458
Suggest me where iam missing in the script.
- Using string comparison where exit value should do:
echo quit > /tmp/sftpcmds.$$
sftp -o ConnectTimeout=3s -q -b /tmp/sftpcmds.$$ user@host >/dev/null 2>&1
case $? in
0) echo OK;;
*) echo "Returned: $?;;
- Using odd paths like "/SFTP/" (see the FHS), dumping files in the CWD and not using mktemp ('man mktemp' for more),
- Using fixed values instead of getopts ('help getopts') and user input ('help read'),
- Probably should be using FUSE SSHFS or AutoSSH,
- Not business-like text but using unnecessary text amelioration like "###" and "---" lines,
- Duplicate echo commands,
- No timeouts / retesting: your "Dear Team," is not going to like you sending emails often.
*Search LQ for "Bash scripting guides".