Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Easy easy question.

Options
  • 14-11-2004 12:21am
    #1
    Closed Accounts Posts: 28


    Ok, basically i have this commandline program (o2SMS for those of you who care), and i want to make it easier to use for myself.

    So, instead of having to open up a dos prompt, and typing "o2sms.exe -u USERNAME -p PASSWORD name-of-person-i'm-texting" i thought i'd write a simple C program to do that for me! Username and password would be hardcoded in.

    Basically, i thought this program would read in a name (char NAME;) and then run the program with a commandline something like this:
    ("o2sms.exe -u USERNAME -p PASSWORD %c", NAME)

    But i can't do this, and i can't seem to find help on the web. I've tried using exec() and fopen(), but i can't seem to get it to work. Any ideas on where i can read up on the right command? Or how to solve my problem :p

    EDIT: ARGH, used the wrong nick... ah well. :p


Comments

  • Registered Users Posts: 6,316 ✭✭✭OfflerCrocGod


    My_PI_Nick wrote:
    EDIT: ARGH, used the wrong nick... ah well. :p
    :D HAhaha I saw the PI and I thought WTF?, on the wrong board mate! :)


  • Closed Accounts Posts: 1,575 ✭✭✭elivsvonchiaing


    Think you want the "shell" method from one of the system API classes - in work I could help you, 'course I would then be fired :)


  • Closed Accounts Posts: 28 My_PI_Nick


    the best i've been able to come up with is:

    execl("o2sms.exe", "o2sms.exe", "-u USERNAME -p PASSWORD Bob", NULL);

    At the moment i'm just trying a hardcoded name (bob :p) trying to get it to work. Basically, this launches the exe, but doesn't pass on that parameters, and afaik it should!

    (i'm gonna continue posting under this nick, as i want to "protect" my real nick from people i know :p)


  • Closed Accounts Posts: 1,575 ✭✭✭elivsvonchiaing


    No Source code in front of me here, just memory (stuff I'd prefer to forget!)...

    Own experience: forget ANSI sh!t - talk to Microsoft API - I'm aware this sucks think it's the truth :(


  • Registered Users Posts: 648 ✭✭✭Tenshot


    Why not use a more appropriate language, in this case the Windows batch environment. Create a file called c:\windows\sendsms.cmd containing:
      @echo off
      o2sms.exe -u USERNAME -p PASSWORD %1 %2 %3 %4 %5 %6 %7 %8 %9
    
    and it should do what you want (which is presumably to be able to open the Run box from your Start menu and type SENDSMS [whoever]).

    If you really want to do it from a C program, here's a simple example:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #define USERNAME	"myusername"
    #define PASSWORD	"mypassword"
    
    int main(int argc, char **argv)
    {
    	char buf[500];
    
    	if (argc < 2)
    	{
    		printf("Error: missing phone number or name.\n");
    		exit(10);
    	}
    
    	sprintf(buf, "o2sms -u " USERNAME " -p " PASSWORD " %s", argv[1]);
    	return system(buf);
    }
    


  • Advertisement
  • Closed Accounts Posts: 28 My_PI_Nick


    In the end i settled for the batch method, and it works grand. It just sounded like a nice easy task to set myself. Read in a name, and then run a program. It all sounded so easy :rolleyes: But, such is life.

    The batch file is perfect for this. I just have to do the following to send a free text from o2.ie now...

    1) Start>Run: "sms *enter name here*." Then hit enter
    2) Type in message in new box
    3) Send.

    I can send a free text in less than 10 seconds now. Which is dead handy when o2.ie decides to go uber slow. Heh heh heh. Muchos gracios amigos!


  • Registered Users Posts: 834 ✭✭✭fragile


    You can just put your username and passsword in the o2smsrc file using the following syntax:

    username whatever
    password whatever


  • Registered Users Posts: 1,865 ✭✭✭Syth


    fragile is right, just use the .o2sms file to store you settings. You can also give aliases to your friends, so you can type something like 'o2sms Jim' and it'll take care of everything.


Advertisement