Skip to main content
removed custom func
Source Link

Actually, neither of the answers above traps the ssh error code and message, which could be done as follows (ignore my custom functionsvars & funcs):

# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && doExitecho $exit_code"$err_msg" $err_msg&& exit $exit_code

Actually, neither of the answers above traps the ssh error code and message, which could be done as follows (ignore my custom functions):

# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && doExit $exit_code $err_msg

Actually, neither of the answers above traps the ssh error code and message, which could be done as follows (ignore my custom vars & funcs):

# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && echo "$err_msg" && exit $exit_code
Corrected indents.. and moved commentary outside of the code syntax
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

Actually, neither of the answers above traps the ssh error code and message, which could be done as follows (ignore my custom functions):

# actually neither of the answers above traps the ssh error code and msg
# which could be done as follows ( ignore my custom funcs )
# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && doExit $exit_code $err_msg
# actually neither of the answers above traps the ssh error code and msg
# which could be done as follows ( ignore my custom funcs )
# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && doExit $exit_code $err_msg

Actually, neither of the answers above traps the ssh error code and message, which could be done as follows (ignore my custom functions):

# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && doExit $exit_code $err_msg
Corrected indents..
Source Link
    # actually neither of the answers above traps the ssh error code and msg
    # which could be done as follows ( ignore my custom funcs ) 
    # move the deployment package from the tmp dir
    msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
    sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
        -a create-relative-package 2>&1)

    # fail on any non-success
    export exit_code=$?
    export err_msg="network error: ""$msg"
    test $exit_code -ne 0 && doExit $exit_code $err_msg
    # actually neither of the answers above traps the ssh error code and msg
    # which could be done as follows ( ignore my custom funcs ) 
    # move the deployment package from the tmp dir
    msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
    sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
        -a create-relative-package 2>&1)

    # fail on any non-success
    export exit_code=$?
    export err_msg="network error: ""$msg"
    test $exit_code -ne 0 && doExit $exit_code $err_msg
# actually neither of the answers above traps the ssh error code and msg
# which could be done as follows ( ignore my custom funcs )
# move the deployment package from the tmp dir
msg=$(ssh -i "$(eval echo $identity_file)" -o ConnectTimeout=5 "$ssh_user"'@'"$ssh_server" \
sudo -iu "$etl_user" bash "$tgt_deployment_dir"'/src/bash/'"$run_unit/$run_unit"'.sh' \
    -a create-relative-package 2>&1)

# fail on any non-success
export exit_code=$?
export err_msg="network error: ""$msg"
test $exit_code -ne 0 && doExit $exit_code $err_msg
Source Link
Loading