Posts tagged: command

sendmail from the command line in GoDaddy

This is another useful tidbit to use with the article, Backing up your Database (with GoDaddy and Cron).

What it does: Allow you to send mail to a specified email address by using the program sendmail.

You do this from the shell in your GoDaddy account. I shouldn’t have to tell you that this tutorial is meant for the shared Linux hosting account.

/usr/sbin/sendmail.real -f

Type that all on one line. Of course, change the addresses to suit your needs, then press <enter>. You’ll be greeted with… nothing happening. sendmail is now waiting for further instructions. So type the following.

Subject: whatever your subject is
And now you type your message below that

And you’ll still be left with nothing happening. Now sendmail is waiting for you to tell it that the message is over. So simply type a period on a line by itself.


And press <enter>. Your message should now send.

This is handy for a cron job where you want either a receipt that the cron job completed, or perhaps you want a file (backup?) sent to you on a regular basis.


/usr/sbin/sendmail.real \
-f \
Subject: Testing for HowTo
This is just a test message.
And this is a new line.

The following email is what I received.

date Mon, Apr 20, 2009 at 2:22 PM
subject Testing for HowTo
This is just a test message.
And this is a new line.

Yet Another Command-Line Twitter

Recently this article made it to the front page of digg. It’s yet another article on how to update your Twitter status from the command line. It covers the bases of how to do it, but I still prefer Wayne’s way over at

First, the script requires cURL to be installed. So install it if it’s not already on your system.

sudo apt-get update
sudo apt-get install curl

I made some minor revisions to the Fsckin way to do it after reading the cURL man page and finding that the –basic flag wasn’t required etc.

It boils down to this

curl --user "username:password" \
--data-ascii "status=`echo $@|tr ' ' '+'`" \

Just copy the text into a file, I’ve called mine “tweet”, and change the username and password to your own information. Note, the text is there for anyone to see who has access to your computer. This is significant as your Twitter password is saved inside that file.

Change the file permission to make it executable:

chmod 755 tweet

And make a tweet on your Twitter profile

./tweet This message is what everyone will see.

which would post the message for everyone to see. You’ll end up getting some output from cURL. So long as it doesn’t come back with a short message which includes

<error>Could not authenticate you.</error>

then we can assume all went well.

Advanced Stuff

You might find that you want to be able to call the “tweet” utility from outside the directory it lives in. You can include the directory in your system path by adding the path to the bottom of your .bashrc

export PATH

So the next time you log in you can just type, from any directory,

tweet whatever the message is

and your twitter profile will be updated.

Personally I like to keep my scripts in a hidden directory in my /home. Something like /home/myusername/.my_scripts (or shorthand: ~/.my_scripts)

How to: Provide a command line argument in C

Question: “How do I read in input from a C program” or “How do I read input from the command line in C” ??

Answer: Easily

Aside from the usual inclusion of stdio.h and stdin.h you just have to loop through the char* array in main.

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
    int i;
    printf ("Number of arguments provided: %d\nThey are:\n", argc);
    for(i=0;i<argc;i++) {
        printf ("%s\n",argv[i]);
    return 1;

The above snippet outputs the following:

./ProgramName MyArgument AnotherArgument
Number of arguments provided: 3
They are:

With the traditional C main method, argc gets the number of arguments provided at the command line. Also, this example assumes the name of the program is “ProgramName” (in C the program name is always the first argument).

Staypressed theme by Themocracy