LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-27-2003, 04:31 PM   #1
ruchika
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Rep: Reputation: 0
Question Pppd does not wait for chat script to finish


Hi,

Pppd man pages mention the following -

"PPPd invokes scripts at various stages in its processing which can be used to perform site-specific ancillary processing. These scripts are ususally shell scripts, but could be executable files instead. Pppd does not wait for the scripts to finish. The scripts are executed as root, so that they can do things such as update routing tables or run privileged deamons."

My questions is - if pppd does not wait for the script to finish how does it know if the script executed/terminated propely or not. More specifically, pppd runs the chat script, now how would pppd know the exit code of chat script if it does not wait for the chat script to finish?

I have a C function that starts the script as follows.
int ret = system("./ppp-on")
printf("%d", WEXITSTATUS(ret));

The ppp-on script looks as follows (only relevant portions have been posted) -

exec /usr/sbin/pppd /dev/ttyS0 115200 persist idle 3600 usepeerdns debug lock modem crtscts noauth bsdcomp 0 deflate 0 kdebug 0 asyncmap 0 connect $DIALER_SCRIPT

The DIALER_SCRIPT looks as follows -

exec /usr/sbin/chat -v
ABORT 'NOCARRIER'
ABORT 'RING'
'' AT
OK ATD$PHONE
TIMEOUT 15
CONNECT ''

The system() call returns immedialtely and prints '0' irrespective of whether the chat script establishes the connection successfully or not. Am I missing something here? I want the C function to know chat was able to establish the connection succesfully or not. How can I do this if pppd returns immedialetly without waiting for chat script to finish?

Any pointers will be highly appreciated.

Thanks.

Ruchika
 
Old 08-28-2003, 11:30 PM   #2
slapNUT
Member
 
Registered: Jun 2001
Location: Recycle Bin
Distribution: Linux & Everything else on VirtualBox
Posts: 144

Rep: Reputation: 15
I think maybe the problem is not in the bash script?

I don't know alot about C programming so I would ask is there a way to call a script that makes the calling function wait for the script to terminate before continuing?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
PPP library & pppd, chat return codes ruchika Linux - Networking 1 03-08-2011 02:50 AM
PPPD Script problem when cron-scheduling the script andresurzagasti Linux - Networking 0 11-24-2004 02:54 PM
bash-script won't wait for application to finish TLV Linux - Software 24 09-30-2004 11:18 PM
pppd/chat error after new slackware install Kanaflloric Slackware 3 09-28-2004 12:05 AM
pppd and chat problem Ricky Linux - Networking 1 10-02-2003 09:05 AM

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

All times are GMT -5. The time now is 11:25 AM.

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