For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > May 2006 > arrow keys in linux









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author arrow keys in linux
tsamisa@gmail.com

2006-05-30, 4:04 am

I'm writing an application that automatically access a webpage and
fills some blanks using lynx. I send char "g" then the url and up to
that point it works fine. My problem is that i can't send the ascii
code (i tried ascii 80,66,25) for arrow dwn in order for lynx to move
to the next i/p field or hyperlink.

Here is the code



#include <stdio.h>

#include <sys/wait.h>

#include <fcntl.h>

#include <unistd.h>

#include <pthread.h>

#include <time.h>

#include <string.h>



void writer ( FILE* stream,int sleeptime)

{
sleep(2);

fprintf(stream,"g");

sleep(1);
fprintf(stream,"www.msn.com\n");
sleep(1);
//here it was supposed to move through the screen
fprintf(stream,"%c",25);

fflush (stream);
sleep (sleeptime);

}

int main(int argc,char * argv[])
{
char lynx[400];
int fds[2];
pid_t pidntw;
FILE *stream;
strcpy(lynx,"lynx");
pipe (fds);
pidntw = fork();
if(pidntw == (pid_t) 0)
{
close (fds[1]);

close(0);

dup2 (fds[0],STDIN_FILENO);

execlp(lynx,"lynx","-accept_all_cookies",0);
return(1);
}
else
{
close (fds[0]);
stream = fdopen (fds[1], "w");
if (ferror (stream) || stream==NULL)
printf("ERROR!! 3\n");
writer(stream,10);
fclose(stream);
close (fds[1]);
waitpid(pidntw,NULL,0);
}
return 0;
}

Thomas Dickey

2006-05-30, 7:07 pm

tsamisa@gmail.com <tsamisa@gmail.com> wrote:
> I'm writing an application that automatically access a webpage and
> fills some blanks using lynx. I send char "g" then the url and up to
> that point it works fine. My problem is that i can't send the ascii
> code (i tried ascii 80,66,25) for arrow dwn in order for lynx to move
> to the next i/p field or hyperlink.


lynx has a log- and command- option pair which is supposed to do this.

The current version of lynx is 2.8.5

It's available at
http://lynx.isc.org/lynx2.8.5/
2.8.6 Development & patches:
http://lynx.isc.org/current/index.html

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com