LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-09-2006, 07:19 PM   #1
tinieprotonjam
LQ Newbie
 
Registered: Dec 2006
Posts: 28

Rep: Reputation: 15
Execute lynx in a c program and make it go to a certain URL


I'm a Linux newbie, and I'm just starting out to do C programming in Linux.
I need to call lynx to go into a certain website from a C program that I already made when a certain key is pressed. I've read that one needs to call a fork() system call to make a child process and to use any of the functions in the exec family (execlp, exeve,execl, and the like)but I seem to have a problem understanding how they differ from one another and which one should I use, and how will I pass the URL I want to visit which is stored as a string.
I will appreciate any suggestions. Thanks in advance.
 
Old 12-09-2006, 08:01 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
A simple way is to use system()
Code:
#include <stdlib.h>
void foo(const char *my_url)
{
char cmd[128]={0x0};
sprintf(cmd,"/usr/bin/lynx %s", my_url);
system(cmd);
}
 
Old 12-10-2006, 11:09 PM   #3
tinieprotonjam
LQ Newbie
 
Registered: Dec 2006
Posts: 28

Original Poster
Rep: Reputation: 15
By the way, thanks jim. I was able to try the code and it works.

I was hoping if there is any other way to do this, since after I quit from lynx, I want to go back to my program (the one that called lynx).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
URL parsing program in perl ludeKing Programming 3 09-30-2010 03:58 PM
make c-program that accepts shell commands and execute them boeroe Programming 4 02-18-2005 08:41 AM
C function to execute a program and return the output of the program ryan.n Programming 4 08-14-2004 10:11 PM
Is it possible to make a Linux server execute a program on a WinXP system? Cichlasoma Linux - General 4 04-23-2004 06:00 AM
how do I make a url handler? Moses420ca Linux - Software 0 09-24-2003 11:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration