Re: running a db2 script using execl
From: Arti Potnis (artpot78_at_yahoo.com)
Date: 06/26/04
- Next message: jd: "Re: /etc/security/passwd"
- Previous message: Dale Talcott: "Re: NFS mount to NAS"
- In reply to: Gary R. Hook: "Re: running a db2 script using execl"
- Next in thread: mark taylor: "Re: running a db2 script using execl"
- Reply: mark taylor: "Re: running a db2 script using execl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Jun 2004 01:14:32 -0700
"Gary R. Hook" <nospam@nospammers.net> wrote in message news:<N9ZCc.8755$BD4.7144@newssvr24.news.prodigy.com>...
> Arti Potnis wrote:
> > I have a C program in which I use the fork a sub shell. I want to run
> > a db2 script in the subshell.
> > my program is as follows:
> >
> > lpid=fork();
> > if(lpid==0) /*child shell*/
> > {
> > execl("home/sqllib/db2","db2","-f","myscript.sql",NULL);
> > }
> >
> > This doesn't work.
>
> Define "doesn't work". We presume it's really "/home/sqllib..." or
> whatever the path really is. FWIW relative paths are evil...
>
> > However if I use a system command i.e. system("db2
> > -f myscript.sql"),it seems to work.
>
> Perhaps it's an environment issue. I.e. certain variables set up
> in the shell but not exported so they don't automatically get
> inherited by children. Just a guess. Try your test with the "/bin/env"
> command to see if you get different output.
>
> > I'm new to using aix and am not sure if using a system command would
> > run this script in the child shell. Do I necessarily have to use execl
> > for this.If yes, then how ?
>
> The system() function creates a child shell that looks just like
> you typed "ksh" on the command line. It is a child process that
> runs and exits when the specified command is complete. You don't
> need to use execl(), since it requires you to call fork(), etc.
> The system() function does all of that for you. But it provides
> less control over file descriptors, and thus has its drawbacks.
--------------------------------------------------------------------
1) By "doesn't work" I mean that the operations that the script is
supposed to perform are not done.The script contains the connect to
db2.. and "LOAD" command for db2.
2)I had used the "which" command to get the path for db2.
I tried using /bin/env but that doesn't solve my problem.
3)Till I figure out a way to use execl for this I'm using system
command
thanks for your response
Arti.
- Next message: jd: "Re: /etc/security/passwd"
- Previous message: Dale Talcott: "Re: NFS mount to NAS"
- In reply to: Gary R. Hook: "Re: running a db2 script using execl"
- Next in thread: mark taylor: "Re: running a db2 script using execl"
- Reply: mark taylor: "Re: running a db2 script using execl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|