
Introduction to PHP Shell Scripting for Linux/Unix Administrators. This course covers helping Unix/Linux Administrators learn about PHP shell scripts. You will learn how to code, and how to convert shell scripts to PHP, and how to use PHP for Web-Based applications.
This section is a brief overview of PHP, and some system related aspects of PHP, that are helpful to know.
PHP is an interpreted language, here are some things to understand about PHP, as opposed to or like PERL.
The unique advantage of PHP, is that you can easily run it over the command line, or through mod_php in apache. Php is also adapt to database connections, with a modern library of current database support.
INI Files are the basis for global PHP configuration, here is where to find them on the system.
The most common values that need to be changed in a PHP INI file are listed in this lesson.
In this section we look at a working script, which compares the contents of two files, they are actually database table dumps, and the script goes and determines which tables are missing from the other file.
First we start with a script, that is written, and explore what it does.
Looking at the files we are searching for, we begin to further understand what the script is doing, and learn about refined parsing methods.
Looking further still we examine and explore the rest of the file, and make deductions about what we might want to change later on.
Now that we understand a bit about the script, we start to modify it, by employing a function to reduce and reuse code.
Now we go and look at some web resources, a good place to find some help.
Now we are going to learn PHP, by building a script.
Let's look at a design template.
Lets turn some code into a function.
This is my most valuable too, the syscall function. Let's learn how it works, and what it allows us to do.
Let's replace the system call with syscall, and measure the result.
Look at ways to implement flexible array processing.
Add a search variable, so that you can easily change what you are searching for.
Instead of one search term, turn that into a passable array.
We look at another way to loop through an array.
Utilize command line arguments to add flexibility to your program.
An introduction into converting a bash script into a PHP script.
Lets take a look at the bash script we are going to convert.
Convert commands to variables.
Use this PHP feature to debug arrays.
Add the Convert FD functionality.
We adjust PHP to match the output formatting, so we get the same functionality as we did with the bash script.
Let's talk about a real-world use case, and discuss how to solve the problem.
Here is a script, which makes a config file, that the main script will use.
To view the config file, we write a short script to display its contents.
Now we take an in-depth look at the main script, and see how to access the data in the config file.
Here is how to configure PHP to send mail. This library works great!
Here is where I got the mail library from, download yourself a copy as well.
Here is a look at the contents of the zip file, so you can examine what the output files look like.
It is always good to use a debug file, this catches all the standard output from the cron job.
Hello, and thank you for you interest in this course. I have been programming PHP since 2000. I have also been a Linux/Unix Administrator since 2000. I have worked with PHP in Shell script applications and Web-Based applications since 2000 as well.
I have written many tools, and managed over 600 servers, and built Linux environments from 2 servers to over 200, in less than 2 years. I have a lot of industry experience, and now I want to share this knowledge with you, so that it can help your career.
In my early days, I was in-between C and Java, and I choose C, and even C over C++, because I was more interested in the systems language that Linux was written in. I grew found of PHP mostly due to its C-like syntax. In fact it is like C, but much easier to pick up. There are no type declarations, or linking, or compiling. It is very easy to go from C to PHP, since most of the functions and operators work the same.
However PHP is even better, since you can write it inline with Web-Based HTML. It makes sys admin work, and web-based reports, only needing to know one language to do both jobs.
With the helper functions that I show you in the course, you will learn how easy it is to turn command line tools, into objects PHP can easily harness. With this you will be able to write scripts fast and quick.
My largest installation of PHP grown scripts, was at a company, where I scripted so much through PHP, that it would have taken 3 full-time people to replace what I had written.
Never fear running out of work, I was always busy at that job, and I never ran out of work, that is why I had scripted so much, just to get ahead and stay afloat. PHP is a powerful language. You can hardness data, and send it right into a database, in fact PHP libraries work with just about every database on the market, making it great glue code to import and export between different platforms.
Enroll now, and let's get started putting PHP to work for you, and letting it enhance and move your career forward.