누구든지이 스크립트가 작동하지 않는 이유를 알고 있습니까?sed에서 변수 교체
파일 이름 : DB 나는 다음과 같은 오류를 얻을 수
#!/usr/local/bin/bash
if [ -z "$1" ]; then
echo "Must specify source DB environment"
echo "One of s (for Staging), p (for Production)"
exit
elif [ "$1" == "s" -o "$1" == "p" ]; then
if [ "$1" == "s" ]; then
echo "Connecting to Staging DB"
URL='staging\.example\.com'
PATH='/var/www/vhosts/staging\.example\.com'
else
echo "Connecting to Production DB"
URL='example\.com'
PATH='/var/www/vhosts/example\.com'
fi
ssh host "mysqldump -udbuser -pdbpass staging | gzip -9" | gzip -d | sed -e "s+$URL+example\.local+g" -e "s+$PATH+/Library/WebServer/Documents/example+g" | mysql -uroot -proot example_local
fi
:
./db: line 14: ssh: command not found
./db: line 14: gzip: command not found
./db: line 14: sed: command not found
./db: line 14: mysql: command not found
주 : ./db
에
- 권한이 777
host
이다는.ssh/config
에 저장됩니다.ssh host
을 실행하여 원격 컴퓨터에 아무런 문제없이 접속할 수 있습니다.- 원격 및 로컬 모두에 대해 mysql 자격 증명이 정확합니다.
- 마지막 ssh one-liner를 명령 줄에서 실행할 수 있습니다. 나는 그것이 sed에서 변수를 대체한다는 것을 확신합니다.
감사합니다.
미안하지만, 나는 내 ... OSX에서 "집"사용자라고 부르는 것을 모른다. @anubhava는 스크립트에 사용중인 서버 경로로 시스템 $ PATH를 겹쳐 쓰는 것이 옳았습니다. –