Pipe output to environment variable export command

$1 is used to access the first argument in a script or a function. It is not used to access output from an earlier command in a pipeline. You can use command substitution to get the output of the git command into an environment variable like this: GIT_HASH=`git log –oneline -1` && export GIT_HASH However… … Read more

Inline if shell script

It doesn’t work because you missed out fi to end your if statement. counter=`ps -ef | grep -c “myApplication”`; if [ $counter -eq 1 ]; then echo “true”; fi You can shorten it further using: if [ $(ps -ef | grep -c “myApplication”) -eq 1 ]; then echo “true”; fi Also, do take note the … Read more

Dash double semicolon (;;) syntax

;; is only used in case constructs, to indicate the end of an alternative. (It’s present where you have break in C.) case $answer in yes) echo ‘yay!’;; no) echo ‘boo!’;; esac Syntactically, ; and & both mark the end of a command. A newline is equivalent to ;, in a first approximation. The difference … Read more

Dockerfile CMD instruction will exit the container just after running it

A docker container will run as long as the CMD from your Dockerfile takes. In your case your CMD consists of a shell script containing a single echo. So the container will exit after completing the echo. You can override CMD, for example: sudo docker run -it –entrypoint=/bin/bash <imagename> This will start an interactive shell … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)