How to check if scp command is available?

I am looking for a multi-platform solution that would allow me to check if a team is available scp.

The problem is that scp does not have a command line --versionand, when called without parameters, returns with an exit code 1(error).

Update: in case this was unclear, by a multi-platform I mean a solution that will work on Windows, OS X and Linux, without requiring me to install anything.

+3
source share
2 answers

Use the command which scp. This allows you to find out if the team and its path are available. If scp is unavailable, nothing is returned.

+5
source
#!/bin/sh

scp_path=`which scp || echo NOT_FOUND`

if test $scp_path != "NOT_FOUND"; then
        if test -x ${scp_path}; then
                echo "$scp_path is usable"
                exit 0
        fi
fi
echo "No usable scp found"

sh , , . , -x - , , , . , , - .

+2

All Articles