I was running a script normally. But suddenly, all the commands in the same line with sshpass started being not recognized. For instance:
sshpass -p "$password" rsync -a -e "ssh -o StrictHostKeyChecking=no -p $port" "$username@$hostname:${src_dir}${dir}/" "${dest_dir}${dir}/"
dirs=$(sshpass -p "$password" ssh -o StrictHostKeyChecking=no -p "$port" "$username@$hostname" "ls -lt --time-style=long-iso '$src_dir' | grep '^d' | head -n 3 | awk '{print $8}'")
These commands run (head,ls and the rest) successfully in other parts of the script. sshpass is installed:
atmos_username@atmosserver:~$ which sshpass
/usr/bin/sshpass
bash: grep: command not found bash: head: command not found bash: awk: command not found bash: ls: command not found rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: error in rsync protocol data stream (code 12) at io.c(231) [Receiver=3.2.7] Copying /mnt/ops/lap_ops/data/KASTOM_OUT/Tiff_files/20240529 to /home/sftp/life-sirius/uploads/Tiff_files/ bash: rsync: command not found
My OS is:
atmos_username@atmosserver:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
Output of declare -p PROMPT_COMMAND
:
atmos_username@atmosserver:~$ declare -p PROMPT_COMMAND
-bash: declare: PROMPT_COMMAND: not found
atmos_username@atmosserver:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Output:
atmos_username@atmosserver:~$ . "/home/atmos_username/2024/ditsiaou_life-sirius/ubuntu_forum.sh"
Attempting SSH connection...
SSH Connection successful.
-bash: /mnt/ops/lap_ops/data/KASTOM_OUT/Tiff_files/: No such file or directory
trial=
bash: head: command not found
bash: awk: command not found
bash: grep: command not found
bash: ls: command not found
dirs= $(dirs)
Copy operation completed.
Delete of 3 days old
Directory /home/sftp/life-sirius/uploads/Tiff_files/20240528/ does not exist.
End of file
20240529 20240530 20240531
PROMPT_COMMAND
to a malformed command that tries to executebash
,head
,awk
etc in~/.bashrc
or somewhere else, what's the output ofdeclare -p PROMPT_COMMAND
?$username
user's login bash shell on$hostname
- most likely thePATH
environment variable is set incorrectly