Saturday 16 February 2013

Why I love linux system programming?


Happy New Year to all my great readers and may this year bring us a lot of blessings. This is my first blog post for the year 2013 and also writing it a day after my end of semester exams. I am enthusiastic over this one month vacation I have at home , I hope to post a few more articles and see to it that we release a killer app @ Oasiswebsoft ( My software dev company ) before I resume school.

I took a break off application programming in November last year to perfect my skills in linux system programming. The main difference between the two is application programming aims to produce software which provides services to the user (e.g. Anansi Calcpad), whereas systems programming aims to produce software which provides services to the computer hardware (e.g. disk clean up).

Even if you think you're not a programmer, Linux has some features to make your life a bit easier. Any time you have a repetitive task that involves entering Linux commands or changing the contents of a file, you should think about automating it with a program in linux.I installed an old version of Ubuntu 11.10 ( It’s a linux distribution and a stable build ) and started playing around with the terminal ; doing some basic stuff like echoing the name of the terminal , writing simple addition programs , sleep , pwd and spent more time online reading  about file permissions ( Read, Write , Execute ) , appending output file ,variables , shell scripting , process structure , for loops and many interesting stuffs.

The Bash shell is your main port of entry to Linux, since the shell interprets everything you enter on the command line before passing it along to the operating system for execution. I fell in love with shell scripting because unlike java you didn't need to assign data types ( Int , float , string , char ) when declaring a variable and you do not need a terminator (semi – colon ; ) in most instances.
eg. In java :
int $num1 = 70;
in shell scripting :
num1 = 20

Often, writing a shell script is much faster than writing the equivalent code in other programming languages like java and python. The many advantages include easy program or file selection, quick start, and interactive debugging. A shell script can be used to provide sequencing and decision-making linkage around existing programs, and for moderately-sized scripts the absence of a compilation step is an advantage. Interpretive running makes it easy to write debugging code into a script and rerun it to detect and fix bugs. Non-expert users can use scripting to tailor the behavior of programs, and shell scripting provides some limited scope for multiprocessing.
We will write a simple script that will allow us to let the bash sleep for a while,  delete all the files that is starts with KLM.
STEP 1: Let’s create three files in the bash terminal
touch klm1
touch klm2
touch klm3
STEP 2: Let’s give all the three files all  permissions rights for the user, group and others.
Chmod 777 klm*
NB: * stands for all files .
To view all files with the date last edited or permission rights and details use this command ls –la (Long listing) and check if all files have all the rights.
STEP 3:
We will now write a simple program in the VI Editor to sleep for 5 seconds and afterwards delete all files.
echo “ Your text here “
Sleep 5
rm klm*
Final step is to execute this program in the main shell. To execute it use this simple command bash and the name of the file in the VI Editor.eg bash killklm

You have now created a simple shell script that automates the process of putting the shell to sleep and deleting the files that start with the word KLM. With just these few lines of code you can easily build a simple program in Linux.These are screen grubs from the simple script we wrote above in the bash terminal and the VI Editor.




Now let’s write a little complex program. This program that will have 5 options eg.
echo "SELECT A NUMBER“
(1 FOR LOVE         (2 FOR DRUGS  (3 FOR SPORTS       (4 FOR HEALTH
(5 EDUCATION  
Each option will contain a text eg. Love : feel tender affection for somebody so when a user choose is a number 1-5 it will display a text.
In the bash terminal you use the cat syntax to input append a text into a file:
Eg: cat > drugs
You will find the complete source code to a dummy program I wrote here on my github repository it contains a for loop and CASE conditions.  Unlike java I did not have to import any special packages to allow the user to input text. Enjoy!!  https://github.com/raindolf/Options-script 

If you've ever written a simple console program ,word processor macro or a spreadsheet formula, you're a programmer. By taking advantage of Linux's built-in programming features, you can automate repetitive tasks and build simple interactive applications without a degree in computer science.Send me a mail if you have any question or contribution iraindolf [at] gmail.com

"Software is like sex: it's better when it's free." Linus Torvalds

15 comments:

  1. that's good stuff there man, that's a loosely typed language you are playing with. Big ups

    ReplyDelete
  2. Hi, nice description about linux system programming.Thanks for your help..

    -Aparna
    Theosoft

    ReplyDelete
  3. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
    Android Online Training

    ReplyDelete
  4. Great stuff about linux. Its is very neat explanation and i learnt lots of new information about linux. thanks for sharing this useful information for our vision. keep posting... Thank you!!!
    Salesforce Training in Chennai | Software Testing Training in Chennai

    ReplyDelete

  5. It was so good to read and useful to improve my knowledge as updated one.Thanks to Sharing



    Hadoop Training In Chennai | Sap MM Training In Chennai | ETL Testing Training In Chennai

    ReplyDelete
  6. Hello everyone 2years back I had $64,000 in debt, including $22,340 in credit card debt. My credit score was nothing to write home about. I managed to get most of my debt removed in bankruptcy and I was left with $8,000 car loan and $35,000 in student loans. I determined not to repeat my mistakes again I was recommended by a credit agency to contact a credit film who would help fix my credit and clear my loans she then referred me to this credit company called Rapid Credit Repairs she has been working with years ago who specializes in fixing credit report. I contacted them through their mail RAPIDCREDITREPAIRS@GMAIL.COM text +1 (415) 754 7204 they got a little info from me and started from raising my credit score to 790 after which they cleared my outstanding pending bills. I bounced back quickly; I am currently on my feet and on my way to buy a house. Thanks so much RAPID CREDIT REPAIRS you guys are simply the best

    ReplyDelete
  7. My name is Andrew Walker, I don’t have much to say but am here to thank TROVIAN CREDIT REPAIRS which i got their contact after visiting my sister and her family and told them my situation at hand how i was knocked out of my home because I was unable to renew rent and my credit profile was messed up in the past. They recommend Trovians to me how they are good in fixing credit, so i contacted them and told them if it’s possible to fix my credit report that has been messed up they gave me a positive answer and they went ahead with the job. In less than 5days my score was raised from a low 478 to 805 excellent and they cleared the eviction, collections late payment. Am happily living well in my new home. I will also recommend you out there to contact them now via email (TROVIANCREDITREPAIR@GMAIL.COM +1 505 926 3648) for your credit repairs services.

    ReplyDelete
  8. My name is Alice and I just want to give a quick review and introduce you to LANX CREDIT SOLUTION, I must tell you that I was skeptical at first about this Company when they told me they’ll remove all the derogatory items in my report, and give me a better FICO. Believe me, giving in to their offer is the best decision I have made in a while, my FICO went from low 485 to a high 780 and my husband’s score went from 612 to 800. We did all they asked us to do and delivered as promised. They removed late payments, some charge offs, eviction and collections. We are still amazed at how awesome this company is. Call them on (310) 879 2541 or email them at LANXCREDITSOLUTION@GMAIL.COM. You also will testify…

    ReplyDelete
  9. Hello there, I have been reading a lot about these credit repair companies and it reminded me of the great job Lanx Credit Solution did for me earlier this year, apparently my fico is still at 765 after 6 months of working with them. Before I contested them my score was as low as 530, had loads of negative items and credit card debts and a Judgement. They helped me tidy it up really good and added some trade lines in it. They are really good at it. Here is their contact just in case in require such service LANXCREDITSOLUTION@GMAIL.COM / +1 (310) 879 2541. Thanks and have a great day.

    ReplyDelete
  10. Do you want a quick, genuine and permanent credit repair? then contact LANX CREDIT SOLUTION via LANXCREDITSOLUTION@GMAIL.COM / call or text (310) 879 2541. I had couple of collections and late payments plus my son’s student loans and some charge offs. My credit score was at the low 560 and needed to get approved for mortgage loan but was denied several times. A colleague told me about this people and how they fixed her credit in 10 days. I was moved so I contacted them on the 2nd OCT 2020 and they fixed my credit before 2 weeks. My score was increased to 790s and the negatives cleared. They promised that the repair is permanent. Big Shout out to them.

    ReplyDelete
  11. Hello everyone, I’m here to announce the good works of HACKNET CREDIT SPECIALIST. For the first time in my life I have never meet such a humble and honest credit specialist like HACKNET. For the past 5years now have been dying with my credit scandal I lost everything including my house, my job, I was left with nothing the whole world seems to end due to my credit report then I meet a friend who referred me to HACKNET that he is the right person to save me from all my troubles after then I contacted him and explained my troubles and we move on with the job, I waited for the couple of days he told me I was surprise when he called asking me to check my credit karma that the deal is done I couldn’t believe what I saw on my report everything was cleaned up including my late payment all marked as paid I got approved for the loans I requested and I’m now on my new apartment. All thanks to HACKNET. You can reach him directly with those contacts
    Email: HACKNET567@GMAIL.COM
    Phone: +1 949 397 8437

    ReplyDelete
  12. Truthfully, taking the decision of contacting a credit repair company was not an easy one, I desperately needed a home, I couldn’t get one due to the evictions and Late payments on my credit, with a very low FICO, I was frustrated and had no choice but try one. Luckily for my I read some very good reviews on LANX CREDIT SOLUTION and decided to contact them. I have never been happier, my FICO was increased to 750 and the late payments and evictions were taken off my report. Superb service I must say!!! You can reach them on LANXCREDITSOLUTION@GMAIL.COM or (310) 879 2541. thanks

    ReplyDelete
  13. I and my husband were in need of fixing our credit. We were having eviction along with our daughter and almost 2 year old granddaughter. We were so tired of struggling and paying awful high rent because we couldn’t buy a house as a result of our bad credit. I went online and I read a lot of good reviews about HACKNET CREDIT SPECIALIST so I contacted him via his contacts; HACKNET567@GMAIL.COM (949) 397 8437. I issued out my credit situation to him and he promised to help me fix my credit within 5days. We got started and after 5days he got back to me with good news. He deleted all the nagging public/negative items and eventually raised my score to 803. We bought a new home and we are living happily ever after as a family. I strongly recommend HACKNET for your credit issues. Thank me later

    ReplyDelete
  14. Amazing unique article direct to the point. Many articles I come across these days do not really provide anything that attracts others as yours, but trust me the way you interact is literally awesome I do respect that so much. I will instantly get your rss feed to stay informed of any updates you make and as well take the advantage to share some vital information regarding the
    10 ROUND GLOCK MAGAZINE FIREARMS which many are not yet informed of it advantages compared to the other rounds. Not over demanding, I will also take the advantage to ask for your permission to join our 179.3k members TELEGRAM CHANNEL
    As to share with us your ideas or any latest update on your blog.
    Thanks

    ReplyDelete