• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

run

Running MySQL commands from the Terminal

November 29, 2020

You can run MySQL commands from the terminal by using -e switch. Here are a few examples.

mysql -u username -p -e "create database mydb"
mysql -u username -p -e "use mydb"
mysql -u username -p database -e "select * from mytable"

mysql -u username -p -e "create database mydb" mysql -u username -p -e "use mydb" mysql -u username -p database -e "select * from mytable"

If you have .mycnf configured, you can omit the username and password.

mysql -e "create database mydb"
mysql -e "use mydb"
mysql -e "select * from mytable"

mysql -e "create database mydb" mysql -e "use mydb" mysql -e "select * from mytable"

To run multiple commands from a single line, separate the commands using a semicolon.

mysql -e "create database somedb; use mydb; select * from mytable;"

mysql -e "create database somedb; use mydb; select * from mytable;"

Filed Under: Linux Tagged With: commands, mysql, run, terminal

Run Ansible Playbook

June 16, 2020

Here’s the command to run the Ansible playbook.

ansible-playbook -t hosts playbook.yml

ansible-playbook -t hosts playbook.yml

Or simply run it like this.

ansible-playbook playbook.yml

ansible-playbook playbook.yml

Filed Under: Linux Tagged With: ansible, playbook, run

Apache Dockerfile

December 25, 2019

This Docker image contains Apache (httpd), a web server.

Here’s the Dockerfile.

FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs/

FROM httpd:2.4 COPY ./public-html/ /usr/local/apache2/htdocs/

Build and run your Docker image.

docker build -t my-app .
docker run -dit --name my-running-app -p 8080:80 my-app

docker build -t my-app . docker run -dit --name my-running-app -p 8080:80 my-app

Visit http://localhost:8080 to view your app.

Filed Under: Cloud, Linux Tagged With: apache, build, docker, dockerfile, run

Run Shell Script From Your Website

September 10, 2019

Here’s how to run a shell script from your website. You’ll need 2 files.

Here’s the contents of foo.php. Wrap your output with ‘pre’ for better formatting.

<?php
$output = shell_exec('/var/www/html/bar.sh 2>&1');
echo "$output";

<?php $output = shell_exec('/var/www/html/bar.sh 2>&1'); echo "$output";

Here’s the content of bar.sh. Output will be displayed on web page.

#!/bin/bash
now="$(date +'%y%m%d')"
echo $now
aws s3 ls

#!/bin/bash now="$(date +'%y%m%d')" echo $now aws s3 ls

Filed Under: Cloud, Linux Tagged With: bash, php, run, script, shell, website

Icecast on Docker

July 5, 2019

Run Icecast2 on a Docker container.

docker run -d \
-p 8000:8000 \
-e ICECAST_SOURCE_PASSWORD=aaaa \
-e ICECAST_ADMIN_PASSWORD=bbbb \
-e ICECAST_PASSWORD=cccc \
-e ICECAST_RELAY_PASSWORD=dddd \
moul/icecast

docker run -d \ -p 8000:8000 \ -e ICECAST_SOURCE_PASSWORD=aaaa \ -e ICECAST_ADMIN_PASSWORD=bbbb \ -e ICECAST_PASSWORD=cccc \ -e ICECAST_RELAY_PASSWORD=dddd \ moul/icecast

Access localhost:8000 on browser. Github.

Filed Under: Cloud Tagged With: container, docker, icecast, run

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023