LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-04-2004, 03:48 AM   #1
ailiez
LQ Newbie
 
Registered: Feb 2004
Posts: 3

Rep: Reputation: 0
C forkpty problem


helo...

i am currently doing a simple program... i want to delete file using the interactive mode without the user inputing the answer through the keyboard... im using C as my programming language...

my program:

main()
{
int fds; //file descriptor
char cSlaveName;
pid_t pid;

if(pid = forkpty(&fds, cSlaveName, NULL, NULL) == 0)
{
execl("/bin/rm", "rm", "-i", "filetobedeleted", NULL);

return 2;
}
else
{
write(fds, "yes", 3);

}
}

as i have understand, the forkpty forks a process, also the filedescriptor takes the stdin, stdout and stderr, however, my write command cannot seems to be recognized by the stdin...

however, i tried reading the out and error... it seems to be working correctly... the writing to the in seems to be a problem...

i hope someone could help me out with my problem
 
Old 02-04-2004, 10:06 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Any reason why you can't use 'unlink'?

Code:
#include <unistd.h>

main()
{
   unlink ("filetobedeleted");
}
 
  


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
forkpty and freezing read Key Programming 2 02-23-2004 10:38 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

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

All times are GMT -5. The time now is 02:32 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