尝试从命令行运行脚本时,为什么我找不到命令?

时间:2014-11-01 00:38:14

标签: bash shell

我正在尝试创建一个脚本并在我的webfaction帐户上运行(运行centos6)。脚本的内容:

#!/bin/sh
# Set environment variables

APPNAME=cpcstage      # Name of the uWSGI Custom Application
APPPORT=18843              # Assigned port for the uWSGI Custom Application
PYTHON=python2.7           # Django python version
DJANGOAPP=django           # Django application name
DJANGOPROJECT=myproject    # Django project name



cat << EOF > $HOME/webapps/$APPNAME/test1/nginx.conf
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    access_log  ${HOME}/logs/user/access_${APPNAME}.log combined;
    error_log   ${HOME}/logs/user/error_${APPNAME}.log  crit;

    include mime.types;
    sendfile on;

    server {
        listen 127.0.0.1:${APPPORT};

        location / {
            include uwsgi_params;
            uwsgi_pass unix://${HOME}/webapps/${APPNAME}/uwsgi.sock;
        }
    }
}
EOF


# make the start, stop, and restart scripts
cat << EOF > $HOME/webapps/$APPNAME/test1/start
#!/bin/bash

APPNAME=${APPNAME}

# Start uwsgi
\${HOME}/webapps/\${APPNAME}/bin/uwsgi \\
  --uwsgi-socket "\${HOME}/webapps/\${APPNAME}/uwsgi.sock" \\
  --master \\
  --workers 1 \\
  --max-requests 10000 \\
  --harakiri 60 \\
  --daemonize \${HOME}/webapps/\${APPNAME}/uwsgi.log \\
  --pidfile \${HOME}/webapps/\${APPNAME}/uwsgi.pid \\
  --vacuum \\
  --python-path \${HOME}/webapps/\${APPNAME} \\
  --wsgi \${APPNAME}_wsgi

# Start nginx
\${HOME}/webapps/\${APPNAME}/bin/nginx
EOF

cat << EOF > $HOME/webapps/$APPNAME/test1/stop
#!/bin/bash

APPNAME=${APPNAME}

# stop uwsgi
\${HOME}/webapps/\${APPNAME}/bin/uwsgi --stop \${HOME}/webapps/\${APPNAME}/uwsgi.pid

# stop nginx
kill \$(cat \${HOME}/webapps/\${APPNAME}/nginx/run/nginx/nginx.pid)
EOF

cat << EOF > $HOME/webapps/$APPNAME/test1/restart
#!/bin/bash

APPNAME=${APPNAME}

\${HOME}/webapps/\${APPNAME}/bin/stop
sleep 5
\${HOME}/webapps/\${APPNAME}/bin/start
EOF

如果我运行bash -e test.sh | tee test.log,我会:

: command not found

test.log中没有任何内容。如果我在脚本顶部添加set -x,那么我得到

: invalid option set: -
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]

当我在ssh中手动运行这些东西时,它们可以工作。有什么想法吗?

0 个答案:

没有答案