Linux Blog

PHP Script To Log Into cPanel

Filed under: Shell Script Sundays — TheLinuxBlog.com at 3:47 am on Sunday, February 24, 2008

Earlier this week I made a script that logs into cPanel to check statistics. Basically if you have a webhost that runs cPanel and you wish to log into cPanel for some reason then this script is for you. Once you are logged in you can basically do anything you would want to do. For example my specific use was to log into my cPanel nightly and parse some data provided by AWStats. But with some modification this script could automate anything you can do by hand.

Since this is more of a web project for me I decided to write my cPanel login script in PHP. I found a PHP class to login here. curl is used to fetch the URL’s and I parse the data using PCRE regular expressions. The statistics code is still very basic but I thought I would post it for those interested and what better place then The Linux Blog’s Shell Script Sundays column?

Onto the script.

It consists of three scripts each with their own purpose in run time. They are as follows:

cPanel.php – This script does all of the dirty work in connecting to cPanel and fetching the pages. I modified this from the original a little
class.mysql.php – Just a generic data base handler. MySQL configuration information is stored in here.
login.php – This is the script that starts off the process. I named it login.php instead of index.php so that I do not have it run as the default page in my web browser. login.php also does all of the parsing of the data and is where the data gets inserted into the database.

To run the script edit login.php and then you can either put it in your PHP powered web server directory or run it from the command line by doing:

php login.php

The output should be as follows:

Num: 0 Date: 2454521 uniques: X visits: X visits per visitor: (Xvisits/visitor) pages: X pages per visitor: (XPages/Visit) hits: X hits per visitor: (XHits/Visit) bandwidth: X GB bandwidth per visitor: (XMB/Visit)

Feel free to modify this as you wish. If any questions can be answered I’d be happy to do so. I’d like to hear what people are using this for too, so drop a comment!

Download the PHP cPanel Login Script

Optimus Maximus OLED keyboard – Linux Support

Filed under: Linux Hardware — TheLinuxBlog.com at 8:00 pm on Friday, February 22, 2008

I was reading a post on Tech.Blorge and thought I’d write a little about it.

I think that this keyboard is a little over priced at the moment, but the price is sure to drop. If I got my hands on one of these here are the things that I would do with it:

  1. Impress my friends
  2. Make it have some kind of fireworks effect where every key you hit makes some sort of explosion on the keys around it. Who doesn’t love fireworks?
  3. Matrix Keyboard. This would be pretty sweet. Just have it constantly waste power by scrolling the Matrix code down it all the time. No one will ever use your computer because they won’t be able to figure out where that blasted key they are looking for is.
  4. Write a movie player so that I could watch a movie on my keyboard instead of working.
  5. Make a game that tests hand eye-coordination. Kind of like BrainAge except you use your hands and don’t have a 1″ screen.
  6. Gaming. I’d love for my keys to change when I play any game. Lets take Quake or Halo for example. It should always flash the mother of all weapons the either the B.F.G or the Rocket Launcher.

I love the shift feature and the special characters feature is pretty cool too but there are better practical uses of this keyboard:

  1. System Stats. Lets say WiFi signal strength, CPU load and memory usage Why display them in Torsmo, gkrellm or anything else you can just move your fingers and see the percentage of memory being used.
  2. Syntax highlighting while programming. I think that this would be a nice feature for new developers and for programmers not familiar with a particular programming language. An example would be the IF syntax. Once you type if, the space bar highlights. Next the left parenthesis then the quote depending on which programming language you use.

If any one gets one of these working I’d love to see it in action. I also thing it should be mandatory that when your OS crashes (no matter what OS your running) it displays the B.S.O.D.

MacBook Air Alternatives

Filed under: Linux Hardware — TheLinuxBlog.com at 6:03 am on Tuesday, February 19, 2008

Ok, so there that been a lot of smugness in the Apple community about the new MacBook Air, which I must say is a stunning looking notebook. Although tiny it is still not the lightest of notebooks weighing in at 3.0 pounds. Here I’ve got an alternative to the MacBook Air. Although not as pretty it should get the job done.

This is a slightly slower Core 2  Duo at 1.2GHz and a 12.1″ Screen but its a worthy laptop for any road warrior

The Portege R500.  Right from Toshibas website comes this statement:

The Ultimate Ultraportable
With its ultralight design and stunning silhouette, the feather light 1.72 pound* Portégé® R500 Series is the transcendent expression of executive mobility and style. Offering the world’s lightest* widescreen 12.1″ notebook PC in one configuration, and the world’s thinnest widescreen 12.1″ notebook PC with an integrated DVD-SuperMulti drive in another, the Portégé® R500 Series represents an uncompromising synthesis of portability and productivity that’s meticulously engineered for the demands of executive computing.

*Lightest model configuration of 1.72 lbs is based on a 64GB solid state drive (SSD), a 3 cell battery and no optical disk drive. The Portégé® R500 with the solid state drive will not be available until the end of July 2007. Weight may vary. See Weight Legal Footnote at www.info.toshiba.com.
Here are the dimensions:

• Dimensions (WxDxH Front/H Rear): 11.1” x 8.5” x .77”(f)/
1.0”(r) without feet
• Weight: Starting at at 2.4 lbs, depending upon
configuration10
• LCD Cover Color: Aluminum Silver

It boasts on the flyer that its the worlds thinnest 12” widescreen which I can believe since it is .01” Thicker in the thinnest part then the MacBook Air. Don't think that with the lack of size on this laptop that you get skimpy options like the MacBook Air either. You get Three, yes I repeat Three USB 2.0 ports, Firewire, Gigabit Ethernet, a/g/n wifi for all of your wireless internet needs. 1 Type II PCMCIA slot, an optional DVD Burner a 6 Cell 5800mAh battery, SD Slot and all kinds of other goodies that you would expect from a laptop. I'm sure if they removed some of these lovely features they could make it thinner. It has the same resolution as the MacBook Air but is a little skimpy on the RAM with 1GB but makes up for it with a 3 year warranty on the hardware and a 1 year warranty on the battery.

They claim that you can get 8.18 hours from this battery so I'd love to get my hands on one of these to play around with powertop to see if it could get even more.

Lenovo have some sweet ThinkPads that are under 3lbs also. I can't find the exact measurements of them but I'm sure they don't come close to the Toshiba or the Air. Actually looking at these specs I think I got a pretty decent deal on my Toshiba Tecra M2 which has done me good so far. It has the following dimensions: 12.3” x 10.1” x 1.2/1.4” and is apparently 4.98 lbs although it feels more like 6. Its a single core 1.7 but I bet you it will boot faster than the MacBook Air. Resume also works too. All in all I probably saved about $1300 by purchasing my laptop. I think they still have some of the Tecra's I have left, they are a pretty good deal at ~$420. Shoot an e-mail if your interested.

cURL Gotcha’s

Filed under: Shell Script Sundays — TheLinuxBlog.com at 4:31 pm on Sunday, February 17, 2008

I’ve been using cURL for a couple of projects recently and I thought I would just post a couple of the “Gotcha’s”

Feel free to add to the list by leaving a comment.

1) User Agent. Certain websites especially Google like to block the use of curl because some people use curl for abusive reasons. This can be fixed by changing your user agent.

User Agents can be switched with curl by using the -A or –user-agent switch.

To change your user agent to Internet Explorer 7 or IE7 on Vista do the following when requesting a page:

curl -A "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" [URL]

Should you want to change your user agent to Netscape 4.8 or Opera 9.2 on Vista you can use the following agent strings:

Netscape user agent string

Mozilla/4.8 [en] (Windows NT 6.0; U)

Opera user agent string

Opera/9.20 (Windows NT 6.0; U; en)

2)  Separate post data with ampersands or put spaces in between your -d’s  This one got me once.

3) Don’t try to post and try to use -G for get requests if you want to post data.

-G makes everything that is in -d get put into a get request instead of a post. Use the following format if you want to post and use get requests.

curl -d "post=data&more_post=moredata" urlgoeshere.php?get=getdata

I’ll post more of these as I remember them, again as stated above if something has got you with curl post them here and I’ll add it to the list with a link to your site! Thats all for this week – Owen.

What Linux Topics Should I Blog About?

Filed under: The Linux Blog News — TheLinuxBlog.com at 6:13 am on Tuesday, February 12, 2008

I just have a few quick questions for everybody so I’ll try to keep this short.
I’ve been blogging (sort of) for almost a year on this blog now and would like to know what keeps you coming back?

I’ve tried to keep the topics related to what I would want to read about. With Linux its hard to not blog about something that isn’t written some where else (which is part of the beauty of Linux) but what does everybody want to read about?

I could post articles that I’ve found explaining how to do certain things, link to other peoples articles / videos or I could continue to do what I’ve been doing.

One thing I would like to see is more participation from my readers. If you have a blog, feel free to comment and link back to your blog posts or give examples. Call me out when something doesn’t work or I’m wrong, I won’t be offended. Comments are moderated to prevent spam, but once you’ve commented once, you are pretty much pre-approved.

One last time (at least for this month) I’m looking for people to write for The Linux Blog. I’m looking for all levels of Linux users from the novice to the quote un-quote “Linux Expert”. Basically I’m looking for more reader participation. I put quite a bit of thought and hard work into maintaining this blog and don’t think its too unreasonable to ask for this. Especially since the advertising doesn’t seem to be working out.

Oh, BTW I’m still working on an OpenSource Bomgar solution :)

Until next time, be safe!

Easy script to upload to an ftp server

Filed under: Shell Script Sundays — Kaleb at 11:43 am on Sunday, February 10, 2008

This weeks Shell Script Sunday article is a guest post by Kaleb. Kaleb has been helping me out a by writing for me since I have a project for The Linux Blog that I’d like to complete and can’t dedicate as much time to writing right now. So if you get a chance visit his site and drop some comments.

Hello it’s Kaleb from http://kpstuff.servebeer.com again and today I have come to tell you about a little shell script that I wrote. It’s a script that allows for extremely easy and simple uploads to an ftp server.

The script is actually quite simple utilizing just standard bash scripting along with ncftp which is just an ftp client with some special features. So you need to install ncftp in order to use this script.

Gentoo:

emerge -av ncftp

Arch Linux:

pacman -Sy ncftp

Ubuntu:

apt-get install ncftp

After you install that you need to edit the upload.sh file to fit your needs. There are a few variables you need to change such as your username and password for the server, and the server itself. It is fairly simple to configure.

Set the user variable to your username

user="kaleb"

Set the passwd variable to your password

passwd="kalebspass"

Then you need to set the server variable to your server you want to connect to

server="kpstuff.servebeer.com"

Be sure to not precede the url with something like http:// or ftp://

Finally you should set the default directory on the server for your file to be placed into.

DIR="/home/$user"

Use $user for your username

Also if your system is odd you may need to make sure that /usr/bin/ncftpput exists. if it does not you will need to find out where on your system ncftp is and change the variable FTPCOM to suit your system.

Now all you need to do is run “chmod +x upload.sh” or “chmod 755 upload.sh” to make it executable and you are finished.

Usage for this script is quite simple. all you need to do is:

./upload.sh <FILE>

Making sure to replace FILE with the filename of the file you want to upload

And if you want to temporarily send the file to a different directory then you specified in the file.

./upload.sh <FILE> <DIR>

Remember to replace with the file you want to upload and replace

with the directory you want to upload to.

You can obtain the script at this address http://kpstuff.servebeer.com/~admin/scripts/upload.sh . And that is it thank you very much for your time and I hope that this script helps you out and if not at least gives you ideas.

Linux Valentines Day Gifts

Filed under: General Linux — TheLinuxBlog.com at 8:42 am on Friday, February 8, 2008

Valentines Day is coming up pretty fast. If you searched for this term you are probably wondering,

“What should I get my Linux Geek for Valentines Day?”

If this is the case this article should give you some ideas

Unless your into roll playing dressing up as Tux (The Linux Penguin) is not really sexy. If you want to do something sexy for your Geek you may have to do something a little Risque. You’ll have to find your partners stance on BSD first and see how they react to it. Possibly bring it up in conversation some how. If your geek doesn’t blow up in a rage that you mention an inferior operating system then you probably be able to get away with my favorite and the first option (if you do this every one who reads The Linux Blog will want to see the pictures):

1) The BSD Daemon Uniform. This could be an interesting gift, or more of a gesture. Dressing up like the BSD Daemon. Its simple and easy and is pretty much a guaranteed evening of fun (providing your partner can be torn away from their PC)

2) TOYS! No, not those sort of toys, I’m talking about gadgets. Buy a gadget or a new Linux compatible piece of hardware. If you yourself are not into Linux it may take you a while to find a piece of hardware that works with Linux but the time you spend will show the dedication you have for your partner.

3) Candy. Who doesn’t like candy? Just make sure that the candy has enough sugar in it to leave your geek energized for the period of time you will need them for on valentines day. Make sure that backups are available or caffeine is readily available.

4) Providing you are both of age alcohol is a great option for those feisty geeks who use too many stimulants such as sugar or caffeine. Dampen them with some alcohol. No matter how much they like Jaeger bombs or red bull and vodka’s don’t do it if your geek is too hyper it will only make the night go as usual.

5) Draw on your self. Ok, everybody has seen it in Google. Some one holding up a sign or laying there with sharpie marks that are going to leave a mark for a while. Write Property of: “Your Name Here” with your name, not that text. Or “I love you ‘your geeks name'” or ”root me ‘your geeks name'” This in turn will probably be posted all over the internet and your geek will be famous. Especially if they have some sort of elite handle.

6) Get something nerdy for your self. Ok, more for the both of you. If you normally dress in non nerdy clothes then find something that you would actually wear off of CafePress and find a design. They have all kinds of clothing such as boxers, t-shirts, tank tops, thongs and other goods such as mugs, mouse pads, clocks and more. You can even design your own stuff if your sort of crafty.

7) A Tanning bed pass. Every geek is too pale. Get them what they deserve! A good old pass to the tanning salon. Think about it, the only reason geeks are so pale is because they don’t want to go out side. With a tanning bed pass they don’t have to and they can get a slight tan in as little at 8 minutes.

8) If your Linux geek logs into the terminal (being you don’t know how to use their computer without them typing some wacky stuff) then you might be able to do something really crafty. Every time they log in there is a little file that is read and then displayed. Sort of like a welcome message. If you can figure out how to get to one of those “typey boxes” also known as a terminal you can type something like the following:

cd && echo "I <3 You" >> .profile

Don’t try to copy and paste that you will probably just mess it up and then they will see what you were trying to do. If you can, open up a new terminal type it in there, and then close it when your done. If you just see a huge black screen with nothing else try typing that then:

clear; exit

Hopefully they will forget that they were logged in and you will have a nifty little message every time they boot their computer

9) I mean, unless your geek reads The Linux Blog they aren’t going to have any idea valentines days coming up so do the natural thing: nothing! You can always use the excuse,
“Oh I had something special planned but I thought we could save the money and just spend the night together”

Well, Thats about all the ideas I can think of off of the top of my head. Let me know what you come up with or what gift your Linux geek gets for Valentines day.

Become independent of the system tray using conky.

Filed under: General Linux,The Linux Blog News — Kaleb at 9:19 pm on Thursday, February 7, 2008

Hello everybody it is I Kaleb from over at http://kpstuff.servebeer.com again come to talk today about an app that I have been using for a while but just recently decided to make it fix my dependence of the system tray all together.

If you read my blog regularly you would know that I am not a fan of GUI applications, I use as few of them as possible. I prefer to use command line programs instead for many reasons: one they are faster, two they are easier and quicker to use/access the features that I want from them, and three I just like the way they look.

For a long time I have used the Fluxbox window manager because it is small lightweight and over all pretty. But no matter what window manager I use: Gnome, KDE, Xfce, FluxBox or OpenBox I have always had some dependence on the system tray, which annoyed me a lot.

Some of them things that I liked a system tray for were a static clock that was always in the same spot and I could always look down and see it, also it had a few nice little icons over there for me to use at my will, like for instance, Gmail-Notify which is a little systray applet that will tell you if you have gmail or not and give you a little pop-up if you get new mail. Also this was for a while how i was telling if I had a new message in pidgin.

Then I started thinking to myself,

“All of these things could be done with Conky and I could use Conky for even more.”

So began the transformation.

If you don’t know already what Conky is, it is a little application that will put text in any format and of almost any type of data you want, weather it be the weather report for the day or the week, or your battery status, the day of the week, or your wireless link quality. It blends into your desktop very well and will give you that sweet geekish look that everybody looks for in a desktop.

First we need to install it.

Gentoo:

emerge -av conky

Make sure that you check out the use flags in Gentoo for things like “wifi” and others

Arch Linux:

pacman -S conky

Ubuntu:

apt-get install conky

Now that you have Conky installed it is time for you to figure out where on your screen you want to put it and also how you want it to look. I wont get into to much detail about how to set it up because those things can be figured out by the most green of Linux users. Also there should be an example config file for Conky that came with the install for Gentoo it is /etc/conky/conky.conf. You need to copy this file to ~/.conkyrc and then edit it at your leisure.

It is quite simple to figure out first you decided the main variables for the program then after the word TEXT you decide how your Conky will look on your desktop. What “text” you would like to see and in what fashion. It is here where you will replace your systray.The first thing I wanted my replacement system tray to display was my gmail messages, weather I had emails or not and how many. So I put together a little script that you can obtain from http://kpstuff.servebeer.com/~admin/check_gmail.sh in order to use this script you need to download it. I suggest to put it into a folder such as ~/scripts/ also make it executable with either “chmod 755 check_gmail.sh” or “chmod +x check_gmail.sh” and remember to edit check_gmail.sh for your username and password. Then you need to edit your ~/.conkyrc file under the TEXT area to resemble this

${texeci 60 ~/scripts/check_gmail.sh}

After this I wanted a clock obviously. Now the time variable has almost a million different options for the format that it gives so I will give you an example of how to set it up but you should run “man strftime” to see a full list of formatting options.

${time %I:%M%p}

This will put a time format on your Conky that resembles “02:19PM”

Yes that is right it is that easy and you can almost print anything you want on Conky even RSS feeds, I suggest you try it out at least once, but not just a little install it and run it and it doesn’t work try.

There are literally hundreds of variables that can be used in Conky and those that are not variables can be created using shell/perl/php/and ruby scripts.

For a list of variables go to http://conky.sourceforge.net/config_settings.html and http://conky.sourceforge.net/variables.html

Thank you once more for your time and remember to leave comments for any of the writers for the Linux blog because each of us would sure appreciate feedback on our writings, whether it be good or bad.

New Linux Desktop

Filed under: Linux Hardware — TheLinuxBlog.com at 5:50 am on Wednesday, February 6, 2008

I got a new Linux desktop for use at my office.  All right, so its not entirely new but the price was right!

Here are the specs:

Motherboard: MSI K9N6SGM
CPU: AMD Sempron 3400+ 256 KB Cache, 1808.430 MHz and 3620.23 Bogomips (Slightly more than my laptop)
Ram: 1GB Generic Ram
Hard Drive: 80GB Sata Drive
Power Supply: 350 Watt

Now, considering I only paid around $200 for all of this I think I did pretty good. I already had an fairly new e-machine that was given to me with a fried motherboard, power supply and hard drive, so I used the Case DVD, Rom and CD-RW drive. Its a pretty fast machine so far. The onboard video happens to be a GeForce so I’m happy about my 3D Graphics support.

What is even better is that if you would like to support The Linux Blog and happen to need a new computer, you can call The Tech Fellows at (704) 780-4932 and tell them that The Linux Blog sent you and they will hook you up. Even if you just need parts they can help and normally can match Tiger Directs prices.

I will let you know how the rest of the installation of Slackware goes and post some benchmarks some time.

Links -g Graphical links

Filed under: General Linux,Linux Software — Kaleb at 12:01 am on Tuesday, February 5, 2008

Hello I am Kaleb Porter from http://kps-blog.blogspot.com writing a post here about links -g, the graphical text web browser. I am sure your asking your self by now, “graphical text web browser? that makes no sense.” well your pretty much right.

What links -g is, is the text based web browser “links” in it’s own X window. This gives it the ability to display images which is very neat actually.

links -g google
Neat right?
Links -g still uses the same old links keys that we are used to from our cli versions that we love so dear. And if you don’t use gpm, you can now use your mouse along with your browser. However if your experienced with gpm this feature may be old news to you.So your asking yourself, “Why the hell do I care about this?” well links -g is an amazingly fast web browser. So if your like me and completely upset at the horrid speed of today’s full featured web browsers… Opera, Firefox, or if your in MacOS Safari, and IE for Windows, then you will love the super fast speed of links -g. Also if your the type of person I am who just flat out likes the simple stuff, or the power user using a nice tiling window manager like dwm or something and you want to be able to display images in your web browser, then you will love links -g.

Sounds great eh? Well it truly is there are drawbacks however most of who will want to use links -g don’t mind these so called drawbacks.
1. Flash.
OK OK so it doesn’t support flash playback…big deal, hey it’s a TEXT based web browser that just happens to be running in X so to support images. You have to give it credit for doing that. And doing that very well.
2. No built in file browser.
OK for this you might be wondering, “What file browser in my web browser?” Well there is a file browser in Web browsers such as Firefox and Opera. These file browsers allow you do do things like pick a file you want to upload to say Photobucket or something. It can still be done, you just need to know where on your system, the file you want to upload is.
3. Other animation software (Java… etc.)
Well you can’t just expect this thing to have support for super cool animation effects from Java because it just doesn’t have a Java plug-in. Note that this is NOT Javascript. Javascript and Java are two different technologies. Javascript is fully supported under links -g.

To install:

In Gentoo:
Make sure you have the proper use flags set up….(png, jpeg, svga, tiff, javascript, X, and ssl if you want it.

  emerge -av links

In Arch Linux:
Everything should be set up for you on Arch so just make sure you have libsvga installed (it may be installed when you install links as a dependency).

  pacman -Sy links

To run links in graphical mode:

  links -g

or

  links2 -g

Have fun!

Linux Guest Bloggers

Filed under: The Linux Blog News — TheLinuxBlog.com at 10:14 pm on Monday, February 4, 2008

Hello readers! Do you enjoy reading this blog? Let us know!

If you are interested in writing guest blog posts or becoming a writer for The Linux Blog doing so is quite simple! I am looking for Linux Bloggers of all levels that are interested in writing about anything Linux related.

Along with this I have a guest blog post from a blogger called Kaleb. You can visit his blog at http://kps-blog.blogspot.com. His first post will be posted in the early hours of tomorrow morning. Check it out and leave him some feedback!

Next Page »