Tuesday, August 31, 2010

PC Scripts Daily - 08/31/2010

Welcome to the fourth edition of PC Scripts Daily! Again, I didn't post yesterday. For today, I have part three of the Bash tutorial.


Bash Tutorial - Part 3: File I/O

You know how to get input from and output information to the terminal. Now, I'm going to teach you how to do the same with files. This is useful for file processors like sed.

To output information to a file, you use the echo command with the output redirector, >. For example, if you want to echo "Hello World" to a file called foo.txt in the present working directory, you would type echo "Hello World" > foo.txt.

To send the contents of a file as arguments of a command, you would type <command> 'cat <file name>'. When you put a command between backticks, Bash will execute the command and replace it with the output.


Next Edition

Tomorrow, I might post later than 3:00 because I need time to write about the Apple event. I will also have part four of the Bash tutorial.

Sunday, August 29, 2010

PC Scripts Daily - 08/29/2010

Welcome to PC Scripts Daily, third edition! Yeah, I know. I didn't post yesterday. I was busy working on JavaScript.


PC Scripts Enhancements

I wrote some JavaScript to customize PC Scripts. There is a new Page Rendering section on the sidebar. If you click Move Sidebar, the sidebar will be moved to the right. If you click it again, it will move back. If you click Remove Sidebar, the sidebar will be removed. If PC Scripts isn't being rendered correctly (sometimes, the sidebar is displayed twice or three times), clicking Reframe should fix the error. Unfortunatly, your settings are not saved. I'm still working on that.


Apple September Event

On September 1st, I will be releasing PC Scripts Daily later in the day to allow time for me to watch and write about the event.


My Buyers' Guide

If you want to buy something like an iPod Touch or iMac, leave a comment on one of the PC Scripts Daily editions and I will keep track of the item on PC Scripts Daily.


Bash Tutorial - Part 2 - I/O, Variables, and Scripts

If you want to be able to do useful things with Bash, you need to know how to get input from & output information to the terminal. Without that, your programs can calculate things and be very accurate & reliable but it would be impossible to know what the output of these calculations are.

Before you learn I/O, you need to know how to use variables. Variables are small pieces of information stored during a terminal session. As soon as the terminal window or session is closed, all set variables are destroyed. To create a variable, you would type <name of variable>=<value>. For example, if I wanted to create a variable named foo with a value of 1, I would type foo=1. The variable name is not foo, though. It's $foo. This makes it very easy to distinguish between variables & strings.

The echo command outputs data to a command line. If you want to create the well known Hello World program, you would use the echo command. The syntax of the echo command is: echo <what you want to display>. Below is the code & the output:

Code: Output:
echo "Hello World!" Hello World!


To echo a variable, you would type echo $<name of variable>. For example, if I wanted to output the contents of foo (which is 1), I would type echo $foo.

What's the point of programming if you can't get input from anywhere? There is no point! The best way to get input from the terminal is by using the read command. The syntax for this command is read <name of variable>. This will allow the user to type in a value for the specified variable. If the variable specified already exists, it will overwrite the existing value. If it doesn't, it will be created. For example, to ask the user to type in a value for foo2, the following code will be used. In the output, all bold text is typed in by the user:

Code: Output:
echo "Type in a value for foo2:"
read foo2
echo "foo2 is now $foo2"
Type in a value for foo2:
Hi
foo2 is now Hi

To make Bash run a bunch of commands without you having to type them in every time, you can create a script. Once you create a script and run it in Bash, Bash will act as if each line of the script is a command. Using this, you can make programs that other people can use without much effort. To create a script, create a new file with your favorite editor. When you name it, make sure you put .sh at the end (i.e. foo.sh). Type any command you want Bash to execute into the file, one command per line. Before you can run your script, you have to make it executable. Otherwise, Bash will treat it like a regular file, not as a list of commands that it can execute. To make it executable, type chmod u+x <name of file>. This will tell Bash that you are allowed to execute the file. If you want everyone on your system to be able to execute your script, drop the u (user) from the command and the added permissions will apply to everyone. Once you have made your script executable, you (and anyone else you have allowed) can execute the script. To do this, you will need the full path of the script, the .. shortcut, or the . shortcut. If your pwd is not anywhere near the file, you can execute the script by giving the full path. For example, if the script was in your ~/Scripts directory, it can be executed by typing ~/Scripts/foo.sh. If the script is in the parent directory, you can execute it by typing ../foo.sh. If your script is in the pwd, you can execute it by typing ./foo.sh.


Next Edition

That's all for today! Check back tomorrow (hopefully) for Bash tutorial, part 3 and some more stuff!

Friday, August 27, 2010

PC Scripts Daily - 08/27/2010

Welcome to PC Scripts Daily, second edition! There isn't much to talk about today but I tried to put together some content I've been working on for PC Scripts. My computer is still dead so I'm working on my iPod Touch.  


Bash Tutorial - Part 1
 

I have been hard at work on a complete Bash guide. Here is what I have so far. 

The cd command is probably the most basic & important command in Bash. This command changes the current working directory, which can be printed using the pwd (present working directory). For example, if your present working directory is your home folder (~) and you type cd Documents, your present working directory will be changed to ~/Documents. There are a few file path shortcuts that are very important. The . shortcut is the present working directory. The .. shortcut is the parent directory. The . shortcut is not very useful yet but it will come in handy later. The .. shortcut is the easiest way to chage the current working directory to the parent directory. You can do this by typing cd ... Another useful command is ls. ls lists all of the files in the present working directory.

The cat command displays a file. You can either give it the name of a file in the present working directory or the entire path of a file. For example, if you want to "cat" the file foo.txt (located in the present working directory), you would type cat foo.txt. You can also give the entire path of a file that you want to cat. For example, if you wanted to cat foo.txt but foo.txt was in ~/Desktop/ and you weren't, you can type cat ~/Desktop/foo.txt. If foo.txt is very long, you can use the less command. It is the same as cat except you can scroll through the file with the up & down arrow keys. This is useful for large files.


Next Edition

That's all for today! Tomorrow I'll continue the Bash tutorial and maybe some more content.

Thursday, August 26, 2010

PC Scripts Daily - 08/26/2010

Welcome to the daily PC Scripts news, published every day at 3:00 PM! Quite a few rumors have surfaced on the Web recently. I have consolidated all of these things into one place. 


Apple TV Refresh

It's rumored that Apple will be refreshing the Apple TV (rebranded under the name "iTV") on September 1st, along with some other products. The iTV refresh is said to replace the horribly slimmed down interface with iOS! It's also rumored that the iTV will come with a USB camera that can be attached to a TV like a Wii Sensor Bar, enabling FaceTime conversations on your TV.

The processor that would be used to make all of this possible is disputed. Some people say Apple is going to use an even more powerful version of their A4 processor. Other say Apple is going to use AMD's new Fusion APU chip. This chip is not just an extremely powerful CPU; it's also a very advanced GPU! Still others say Apple isn't going to refresh the Apple TV at all! Apple is currently trying to make deals with TV studios to reduce the price of TV episodes on iTunes from $1.99 per episode to just $0.99 per episode. This is probably to make iTV more attractive pricewise than cable TV. Also, because iTV is rumored to run iOS, it could push iOS game developers to the console market. 


Apple September Event

Yesterday, Apple announced that it's holding its traditional September event on September 1st, a whole week earlier  than last year. Anticipated is the refreshed Apple TV, a second generation iPad, a new iPod Touch with a camera, some updated iPods, iTunes 10.0 and iOS 4.1.  

iPad sales have exploded! Because of the over 3,000,000 iPads sold (Sales figures from Wikipedia), the rumors of a second generation iPad are no surprise. Possible features are a camera and voice & FaceTime calls. If that's the case, it's not going to be worth $500 to upgrade if you already own an iPad.    

When the third generation iPod Touch came out, everyone was disappointed that it didn't have a camera. It was even opened up and pictures showed that there was a space for a camera. This time, Apple might add a camera. If this happens, Apple might add FaceTime using email addresses or the Apple Game Center. The form factor of the iPod Touch could be changed to match the iPhone 4. The new iPod Touch might also have a Retina display. The processor that will make this possible will probably be the Apple A4 processor. 

The iPod line might be updated next week. It's possible that the sixth generation iPod Nano will be released that the event. It might feature more storage space and hopefully, a better microphone. The iPod Classic probably won't be updated because there isn't much about it that can be changed. 

In my opinion, the iTunes interface needs to be updated. It is very bloated and has too many features crammed into each section. The interface needs to be redesigned. Syncing files between iTunes and iPads needs to be a lot easier. Also, there needs to be a way to sync iMovie files between iTunes and iPhones.

iOS 4.1 might enable FaceTime calls through email addresses. This is probably because Apple plans to add FaceTime to the iPod Touch, which doesn't have a phone number. It could bring iMovie to the iPad and iPod Touch. 


Internet Explorer 9 Beta

IE 9 Beta is going to come out soon and I can't wait to see how bad it is! Microsoft Russia has leaked a screenshot of IE 9. It looks just like Windows 7 Explorer (file manager). That might not be a good thing. It makes all of the toolbars and bookmarks inaccessable. Oh, well. That's Internet Explorer for you!

Command Command Revolution

Does anyone have any bug reports or ideas for Command Command Revolution? Please leave a comment if you do. I've just been making under the hood changes to it and I would like to make some actual changes to it but I really have no idea what to do. Also, I will try to release Command Command Revolution as soon a my computer is up and running again.

Command Command Revolution 3.0

I have finished working on Commad Command Revolution 3.0 but I can't publish it until I figure out how to get my computer working. The Updates are:

  • Big bug fixes
  • Consolidation of all the scripts in the lib folder
  • Under the hood changes like a new way of storing and running level packs

Dead Computer

My computer is currently in an unbootable state. I am updating this blog and the rest of PC Scripts from my iPod Touch. I cannot figure out what's wrong!


Computer Hardware Specifications

I have a Dell desktop computer, custom-built. It has a motherboard with an integrated graphics card and an integrated sound card. There are a few USB controllers and an 802.3 (Ethernet) port. I also have a PCI internal graphics card (which is the one I use), a PCI internal 802.11 b/g card, and a PCI internal modem. My drive setup is as follows: I have an internal 100 GB Seagate Barracuda IDE hard drive connected as the primary master. This is the drive that my OS and personal files are on. I have an internal IDE DVD-RW drive (I forgot the brand) connected as a secondary master. I have an internal Phillips IDE CD-ROM drive connected as a secondary slave. I have a floppy drive connected as a diskette drive. I have an internal 80 GB Seagate Barracuda IDE hard drive connected through a USB external hard drive case. This is my backup drive.


Computer Software Specifications

My operating system is Ubuntu 10.04.1 LTS.


Problem

I installed some updates via aptitude. It told me I needed to restart my computer, so I did. I always turn on verbose mode rather than stare at the splash screen to make sure nothing goes wrong. This can be done by pressing the up arrow key while the splash screen is up. It said it was running fsck, like always. Then, after the output from fsck (which was completely normal), it got stuck. Normally, it is supposed to say Setting sensors limits, then go to the Gnome Desktop Manager login screen. This time, it just sat there after fsck and didn't do anything else. I can boot from the live CD without errors. I can also chroot into the installed filesystem so if I need to, I can install anything that is necessary to fix this problem. If any more information is required or you know how to fix this, please leave a comment. Thank you.

Tuesday, August 24, 2010

Command Command Revolution 2.3 Patch Released

There was a small bug in CCR 2.2 that caused it to always say that there were no updates. This bug was inherited by CCR 2.3. I have updated the tarball for CCR 2.3 to fix the bug. If you have been trying to update through CCR 2.2 and it has been saying that there are no updates, just download the CCR 2.3 updated version here and install it manually. Once this has been done, future updates should be detected by Command Command Revolution (if you have the updater turned on) and it should download the update without a problem!

Command Command Revolution 2.3 Is Out!



Download Command Command Revolution 2.3 here! The tar file containing ccr is now compressed with 7zip to make it even smaller than before. Please make sure you have the following packages so you can unpack the file:
  • tar
  • p7zip

If you do not have either of these packages, download and install them by typing sudo aptitude install tar && sudo aptitude install p7zip.

Updates:
  • Bug fixes
  • Now licensed under the GNU General Public License
  • Built-in Updates Installer
  • More optimized code
  • Better documented code


Click here to view the warranty and here to view the license.

To install Command Command Revolution, follow these instructions:
  1. Download the tar.7z file here or type wget http://pcscripts.webs.com/bash/ccr/ccr2-3.tar.7z
  2. Open terminal and navigate to the location of the tar file
  3. Type p7zip -d ccr2-3.tar.7z && tar xvf ccr.tar && rm ccr.tar
  4. Type cd ccr
  5. Run ./install.sh as a superuser
  6. Make sure /usr/local/bin/ is in your path
  7. Run ./settingsinstall.sh on all users you want to play ccr on. Make sure you do not run it as a superuser! Run it as the user you want to play ccr on.
  8. Delete the ccr install folder by typing cd .. && rm -r ccr
  9. To play ccr, type ccr.sh in the terminal.

To run Command Command Revolution without having a superuser install it, follow these instructions:
  1. Download the tar.7z file here or type wget http://pcscripts.webs.com/bash/ccr/ccr2-2.tar.7z
  2. Open terminal and navigate to the location of the tar file
  3. Type p7zip -d ccr2-3.tar.7z && tar xvf ccr.tar && rm ccr.tar
  4. Type cd ccr
  5. ./settingsinstall.sh
  6. To run, navigate to ccr/bin/ and type ./ccr.sh.

To install Command Command Revolution on a jailbroken iDevice, follow the instructions below. If you have the package Aptitude, replace apt-get with aptitude in the commands below.
  1. Make your you have either Mobile Terminal or OpenSSH installed
  2. SSH into your iDevice or open Mobile Terminal
  3. Type su
  4. If you do not have the package Tape Archive, install it by typing apt-get install tar. If you don't know whether or not you have it, install it. If you already have it, it will not install anything.
  5. If you do not have the package 7-zip, install it by typing apt-get install p7zip. Again, if you don't know whether or not you have it, install it. If you already have it, it will not install anything.
  6. If you do not have the package wget, install it by typing apt-get install wget.
  7. Type exit
  8. Type wget http://pcscripts.webs.com/bash/ccr/ccr2-3.tar.7z
  9. Type 7z e ccr2-3.tar.7z
  10. Type rm ccr2-3.tar.7z
  11. Type tar xvf ccr.tar
  12. Type rm ccr.tar
  13. Type cd ccr
  14. Type su
  15. Type ./install.sh and hit return when prompted to
  16. Type exit
  17. Type ./settingsinstall.sh and hit return if prompted to
  18. Type cd ..
  19. Type rm -r ccr
  20. Type ccr.sh to play ccr


Credits

Everyone who helped me make CCR better is listed here.

Nanduhirion

Levels
  • Shell Slave: The Servitude
  • Shell Slave: The Rescue

Tarada Linux 10.04 LTS Alpha Is Out!

Tarada Linux 10.04 LTS Alpha has been released! Download it (when it's finished uploading) at the sourceforge.net project and help make it better by reporting any bugs you find in the comments.

Sunday, August 22, 2010

Tanuj's Corner

About a week and a half ago, my brother, Tanuj, got interested in programming. I helped him learn DOS Batch but it soon became obvious he wanted to do more with his programs. I installed an SSH client on his Windows computer so he could SSH into my Linux computer and use Bash. He then wanted to do even more than what Bash could do so I started teaching him C++.

When Tanuj finishes a program he wants posted, I will post it in the Tanuj's Corner section of the blog.

Saturday, August 21, 2010

PC Scripts on Google!

PC Scripts is now indexed by Google! Before, it was not on any of the 500 million pages of items that came up fo the search terms PC Scripts. Obviously, I didn't look at every single page of results. I used a Google page rank tool and it couldn't find PC Scripts on any page. Then, I added the HTML <meta> tag to tell Google to index my page. I also provided a short description of PC Scripts. Now, PC Scripts is the 7th item on the 7th search page. Therefore, I have 76 websites ahead of me because there are 10 results per page.

Friday, August 20, 2010

Polynomial Solver - C++

Over the past week or so, I've been posting different versions of my polynomial solver program on the PC Scripts Forums. Now, I have finished it and I probably won't make any changes to it anymore. The program is object oriented and has three files. For convenience, I have packaged the source into a downloadable tarball. It can be downloaded here. The current version of this program is 1.5.


Compiling in an IDE

To compile this program in your favorite IDE, follow these instructions:

  1. Create a new C++ project
  2. Add a new C++ source file and call it polynomialsolver.cpp
  3. Copy and paste the contents of polynomialsolver.cpp into the project source file
  4. Add a new C++ source file and call it Polynomial.cpp
  5. Copy and paste the contents of Polynomial.cpp into the corresponding source file in the project
  6. Add a new C++ header file and call it Polynomial.h
  7. Copy and paste the contents of Polynomial.h into the Polynomial header file in the project
  8. Compile and run the program how you would any other program in your IDE


Compiling From the Terminal

I have not been able to compile this program from the Linux terminal using GCC. If anyone knows how to compile multi-file object oriented programs using GCC, please leave a comment.


Bugs

There are a few bugs in my program.

  • I can't get the private function PrintPoly() to correctly output the polynomial. This does not affect the answer it gives but it cannot correctly display polynomials like x4-500x2+1000. If anyone knows how to fix this bug, please leave a comment.
  • Outputs errors when the sensitivity of GetValues(). Again, if anyone knows how to fix this, please leave a comment.

Cleaning Your Package Cache - Ubuntu

Do you notice that you are running out of disc space too quickly? After installing a lot of software on Ubuntu, more disc space is used than you think. When you tell your package manager to download and install a package, it has to the downloaded files somewhere! It would be nice to have the packages stored in the RAM but that's not how Ubuntu works. Because of this, to keep your computer running fast, you have to clear the package cache sometimes. This can be done two ways.


Removing Old Dependencies

If you uninstall software from your computer, its dependencies might remain on your system. To uninstall the dependencies, type

apt-get autoremove in a terminal.


Removing Package Archives

If you only want to remove the .deb pre-packaged binaries from older versions of software installed on your computer type

apt-get autoclean in a terminal.


Removing Entire Package Cache

If you want to remove the entire package cache from your system, you will need to install some extra software called Ubuntu Tweak. I will do a full review of Ubuntu Tweak later but for now, let's just get the job we are trying to do done. Once you install Ubuntu Tweak from here, open it and type in an administrator's password if asked to. Click on the second tab under Applications, click the Unlock button, and type in an administrator's password if asked to. Click on the Clean Packages button and check the Select All box. This will not remove the actual programs. It will remove the installers downloaded by your package manager. To remove the installers listed, click on the Clean Up button and wait for Ubuntu Tweak to do its thing. Do this for all of the buttons on the side of the window but do not purge PPAs. The Clean Kernels button will remove the installers for all of your old kernels. If you have never upgraded the kernel, there will be nothing to clean there.


I hope this guide has helped you free up quite a bit of room on your system. Check back soon for a complete Ubuntu Tweak review!

PC Scripts & Internet Explorer

If you are viewing PC Scripts in Internet Explorer, you may be wondering why all of the text on the pages is underneath the text. This is because Internet Explorer doesn't display PC Scripts correctly. Please switch to another browser like Google Chrome, Safari, Opera, or Mozilla Firefox.