Skip to content

Error message while copying but it actually copies the directory #583

@michaelmaalouly

Description

@michaelmaalouly

Hello,

Here is the code that I run:

#!/bin/bash

# Read IPs from the file and store them in an array
IFS=$'\n' read -d '' -r -a IPs < ../IPs

# Loop through each server (IP)
for ip in "${IPs[@]}"; do
echo "Processing server: ${ip}"

# Find the latest directory ending with "_end" in /tmp/ on the remote server
latest_dir=$(clush -w $ip "find /tmp/ -maxdepth 1 -type d -name '*_end' -exec stat --format='%Y %n' {} \; | sort -n | tail -1 | awk '{print \$2}'")

# Check if a directory was found
if [[ -z "$latest_dir" ]]; then
    echo "No directory ending with '_end' found on ${ip}"
    continue
fi

echo "Latest directory found: $latest_dir"
echo $ip
# Copy the latest directory to the local folder (current directory)
clush -w $ip --rcopy "$latest_dir" --dest=./ || { echo "Error copying directory from ${ip}"; exit 1; }

echo "Directory successfully copied from ${ip}"
done  

Since I am looking through the IPs, I know that I can use ssh and scp but as a first try I had all my codes using clush so I kept it and I get the following output from this code:

Processing server: 10.101.30.53 Latest directory found: 10.101.30.53: /tmp/20250214-150448_end 10.101.30.53 10.101.30.53: scp: 10.101.30.53:: No such file or directory clush: 10.101.30.53: exited with exit code 1 Directory successfully copied from 10.101.30.53

Since the code executes and copies, I assume this might be a bug? or I might be misusing clush..

Thanks for the help!
Michael

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions