Linux Terminal Scripting and Executable PHP Scripts

  • Episode 314
  • September 24, 2013

Learn to write bash scripts in Linux which support multitasking asynchronous execution, and running PHP scripts from the terminal.

This video is provided free of charge. If you enjoy what we do, please consider becoming a Patron so we can continue offering more great content.
Support This Free Content
This episode marks six years of Category5 Technology TV.
This episode is sponsored in part by: Eco Alkalines.

Topics Covered:

  • Robbie Ferguson and Christa Wells present live from the Category5 studios in Barrie, Ontario.
  • {play 4:05}Our new transcoders are averaging around 5 episodes per day. We expect this to increase over the next week.
  • {play 6:45}Shout out to long-time and new viewers.
  • {play 12:32}Robbie is developing his own Content Management System, and he's having a blast writing sophisticated jQuery code.
  • {play 14:31}Feature: Introduction to scripting in the Linux terminal, with multitasking.
    • Creating a directory to work in.
    • Using nano to edit a new script in the Linux terminal.
    • Adding a shebang and specifying the interpreter of our script.
    • Making your script executable with chmod +x.
    • Grabbing some high-resolution images from
    • Writing a simple bash script which uses wget to download five images from a web server.
    • Hard-setting the download speed of wget—in our case, so we have an apples-to-apples scenario, but you might use this to prevent your script from maxing out your Internet bandwidth.
    • Specifying the output file for wget downloads.
    • Writing a very simple timer so we know how long our script takes to complete.
      start=`date '+%s'`
      # do all your stuff
      end=`date '+%s'`
      echo $(($end - $start))
    • Making our bash script asynchronous / mutlitasking, so our tasks can run simultaneously rather than having to wait for each download to complete before beginning the next.
    • Timing the results: our timer demonstrates that multitasking the same commands to download images completed in only 41% of the time—69% faster time to completion of the same task.
    • Final script from this example:
      start=`date '+%s'`
      wget --limit-rate=200k -O 1.jpg &
      wget --limit-rate=200k -O 2.jpg &
      wget --limit-rate=200k -O 3.jpg &
      wget --limit-rate=200k -O 4.jpg &
      mogrify -resize 640x360 *.jpg &
      end=`date '+%s'`
      echo $(($end - $start))
      echo done
    • What kind of downfalls are there to multitasking your script?
    • Adding mogrify to our script (as per Episode 310) but forcing it to wait for the downloads to complete before resizing the images.
    • Running PHP scripts on Linux from the command line.
    • Installing php5-cli, curl and php5-curl to build executable PHP code which utilizes the cURL library.
    • Break for the news
  • {play 35:32}Top Stories from the Category5.TV Newsroom
    • The iPhone 5s TouchID was hacked within days of launch.
    • HP is stocking Ubuntu-powered laptops in 1,500 of its stores in China.
    • A new home theatre chair vibrates and pulses in time with your surround sound.
    • Valve has announced SteamOS – a Linux-based Steam operating system.
  • {play 47:03}Feature (Resume): Continuing where we left off before the news.


Technology TV
Episode 658 Live:

Being Watched

Twitter Posts

Login to Category5

Error message here!

Hide Error message here!

Forgot your password?

Register on Category5

Error message here!

Error message here!

Hide Error message here!

Lost your password? Please enter your email address. You will receive a link to create a new password.

Error message here!

Back to log-in