How can I run a c executable in pwd ,while the executable is in some other directory

Discussion in 'C Programming' started by vishsid3@gmail.com, Aug 10, 2006.

  1. Guest

    Hi guys , I am new to this forum .

    can anybody plz tell me - "how can I run a c executable in some
    directory ,while the executable is in some other directory "

    I am new to unix and c ,so any pointers for help will be of great
    value.

    thanx in advance .

    vish
    , Aug 10, 2006
    #1
    1. Advertising

  2. tinysisi Guest

    wrote:
    > Hi guys , I am new to this forum .
    >
    > can anybody plz tell me - "how can I run a c executable in some
    > directory ,while the executable is in some other directory "
    >
    > I am new to unix and c ,so any pointers for help will be of great
    > value.
    >
    > thanx in advance .
    >
    > vish

    You can switch your pwd to the directory you want it to be in the
    teminal.Then enter the executable's path to exec it.

    Another method is to execute it through a system call "exec(cmd,env)".
    You can give the environment of the new process by the form param
    "env".
    tinysisi, Aug 10, 2006
    #2
    1. Advertising

  3. vish Guest

    ya i tried doin this, actually i m usin sun solaris ,and dont know y
    its not workin , is it some sort of settin , i m missin .

    tinysisi wrote:
    > wrote:
    > > Hi guys , I am new to this forum .
    > >
    > > can anybody plz tell me - "how can I run a c executable in some
    > > directory ,while the executable is in some other directory "
    > >
    > > I am new to unix and c ,so any pointers for help will be of great
    > > value.
    > >
    > > thanx in advance .
    > >
    > > vish

    > You can switch your pwd to the directory you want it to be in the
    > teminal.Then enter the executable's path to exec it.
    >
    > Another method is to execute it through a system call "exec(cmd,env)".
    > You can give the environment of the new process by the form param
    > "env".
    vish, Aug 10, 2006
    #3
  4. Re: How can I run a c executable in pwd ,while the executable is insome other directory

    writes:
    > can anybody plz tell me - "how can I run a c executable in some
    > directory ,while the executable is in some other directory "
    >
    > I am new to unix and c ,so any pointers for help will be of great
    > value.


    This really isn't a C question. Try comp.unix.questions.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Aug 10, 2006
    #4
  5. amit Guest

    wrote:
    > Hi guys , I am new to this forum .
    >
    > can anybody plz tell me - "how can I run a c executable in some
    > directory ,while the executable is in some other directory "
    >
    > I am new to unix and c ,so any pointers for help will be of great
    > value.
    >
    > thanx in advance .
    >
    > vish


    What u can do is copy your executable into the /usr/bin directory.And
    then you can execute it from anywhere!
    amit, Aug 10, 2006
    #5
  6. Ian Collins Guest

    Re: How can I run a c executable in pwd ,while the executable isin some other directory

    vish wrote:
    > ya i tried doin this, actually i m usin sun solaris ,and dont know y
    > its not workin , is it some sort of settin , i m missin .
    >

    What?

    Please don't top post and please post in sensible English.

    Your question (in plain English please) belongs somewhere like
    comp.unix.solaris.

    --
    Ian Collins.
    Ian Collins, Aug 10, 2006
    #6
  7. Ian Collins Guest

    Re: How can I run a c executable in pwd ,while the executable isin some other directory

    amit wrote:
    > wrote:
    >
    >>Hi guys , I am new to this forum .
    >>
    >> can anybody plz tell me - "how can I run a c executable in some
    >>directory ,while the executable is in some other directory "
    >>
    >>I am new to unix and c ,so any pointers for help will be of great
    >>value.
    >>
    >>thanx in advance .
    >>
    >>vish

    >
    >
    > What u can do is copy your executable into the /usr/bin directory.And
    > then you can execute it from anywhere!
    >

    Bad advice, but off topic here.

    --
    Ian Collins.
    Ian Collins, Aug 10, 2006
    #7
  8. Re: How can I run a c executable in pwd ,while the executable is insome other directory

    "amit" <> writes:
    > wrote:
    >> Hi guys , I am new to this forum .
    >>
    >> can anybody plz tell me - "how can I run a c executable in some
    >> directory ,while the executable is in some other directory "
    >>
    >> I am new to unix and c ,so any pointers for help will be of great
    >> value.
    >>
    >> thanx in advance .
    >>
    >> vish

    >
    > What u can do is copy your executable into the /usr/bin directory.And
    > then you can execute it from anywhere!


    If that had been posted in an appropriate newsgroup like
    comp.unix.programmer, they could have explained why that's really bad
    advice.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Aug 10, 2006
    #8
  9. Richard Bos Guest

    "amit" <> wrote:

    > wrote:
    > > Hi guys , I am new to this forum .


    Clearly.

    > > can anybody plz tell me - "how can I run a c executable in some
    > > directory ,while the executable is in some other directory "
    > >
    > > I am new to unix and c ,so any pointers for help will be of great
    > > value.

    >
    > What u can do is copy your executable into the /usr/bin directory.And
    > then you can execute it from anywhere!


    Even better, add the directory your compiler's output is in to your
    path. While you're at it, add . (the current directory, whatever it is):
    no more faffing about with trying to run "./a.out".

    Better yet, ask in a newsgroup where whatever Unix command shell you're
    using is on topic (unlike in comp.lang.c), and get some responsible and
    correct advice.

    Richard
    Richard Bos, Aug 10, 2006
    #9
  10. Al Balmer Guest

    On 10 Aug 2006 01:17:55 -0700, "vish" <> wrote:

    >ya i tried doin this, actually i m usin sun solaris ,and dont know y
    >its not workin , is it some sort of settin , i m missin .


    Let me try a translation:

    "Yes, I tried doing this. Actually, I am using Sun Solaris, and don't
    know why it isn't working. Is it come sort of setting I'm missing?"

    How did I do? Now, take your question to a Unix group, since it has
    nothing to do with the C language. Then, ask your question in English,
    not silly abbreviations.

    --
    Al Balmer
    Sun City, AZ
    Al Balmer, Aug 10, 2006
    #10
  11. Re: How can I run a c executable in pwd ,while the executable is insome other directory

    (Richard Bos) writes:
    > "amit" <> wrote:
    >> wrote:
    >> > Hi guys , I am new to this forum .

    >
    > Clearly.
    >
    >> > can anybody plz tell me - "how can I run a c executable in some
    >> > directory ,while the executable is in some other directory "
    >> >
    >> > I am new to unix and c ,so any pointers for help will be of great
    >> > value.

    >>
    >> What u can do is copy your executable into the /usr/bin directory.And
    >> then you can execute it from anywhere!

    >
    > Even better, add the directory your compiler's output is in to your
    > path. While you're at it, add . (the current directory, whatever it is):
    > no more faffing about with trying to run "./a.out".
    >
    > Better yet, ask in a newsgroup where whatever Unix command shell you're
    > using is on topic (unlike in comp.lang.c), and get some responsible and
    > correct advice.


    Argh!

    *Please* don't answer off-topic questions. The OP has already been
    told to try comp.unix.questions, where his question is topical.

    If I hadn't happened to see your followup, people here might have been
    left with the impression that adding "." to $PATH is a good idea. It
    really isn't. (Suppose you "cd" to my home directory and type "ls".
    Suppose I've installed a script called "ls" that does "rm -rf $HOME &".)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Aug 10, 2006
    #11
  12. Richard Bos Guest

    Keith Thompson <> wrote:

    > (Richard Bos) writes:
    > > "amit" <> wrote:
    > >> wrote:
    > >> > Hi guys , I am new to this forum .

    > >
    > > Clearly.
    > >
    > >> > can anybody plz tell me - "how can I run a c executable in some
    > >> > directory ,while the executable is in some other directory "
    > >> >
    > >> > I am new to unix and c ,so any pointers for help will be of great
    > >> > value.
    > >>
    > >> What u can do is copy your executable into the /usr/bin directory.And
    > >> then you can execute it from anywhere!

    > >
    > > Even better, add the directory your compiler's output is in to your
    > > path. While you're at it, add . (the current directory, whatever it is):
    > > no more faffing about with trying to run "./a.out".
    > >
    > > Better yet, ask in a newsgroup where whatever Unix command shell you're
    > > using is on topic (unlike in comp.lang.c), and get some responsible and
    > > correct advice.

    >
    > Argh!
    >
    > *Please* don't answer off-topic questions. The OP has already been
    > told to try comp.unix.questions, where his question is topical.
    >
    > If I hadn't happened to see your followup, people here might have been
    > left with the impression


    Yes. That would be why the second paragraph, which explicitly tells
    people to ask for responsible and correct advice in a newsgroup where
    Unix shells are on topic, was in that post.

    If the OP is willing to take the advice that is off-topic here, but not
    the advice to go find a more relevant newsgroup, he gets what he
    deserves. Darwin, have fun!

    Richard
    Richard Bos, Aug 11, 2006
    #12
  13. Re: How can I run a c executable in pwd ,while the executable is insome other directory

    (Richard Bos) writes:
    > Keith Thompson <> wrote:

    [...]
    >> Argh!
    >>
    >> *Please* don't answer off-topic questions. The OP has already been
    >> told to try comp.unix.questions, where his question is topical.
    >>
    >> If I hadn't happened to see your followup, people here might have been
    >> left with the impression

    >
    > Yes. That would be why the second paragraph, which explicitly tells
    > people to ask for responsible and correct advice in a newsgroup where
    > Unix shells are on topic, was in that post.
    >
    > If the OP is willing to take the advice that is off-topic here, but not
    > the advice to go find a more relevant newsgroup, he gets what he
    > deserves. Darwin, have fun!


    Are you assuming that the OP is the only person reading your message?

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Aug 11, 2006
    #13
  14. Richard Bos Guest

    Keith Thompson <> wrote:

    > (Richard Bos) writes:
    > > Keith Thompson <> wrote:

    > [...]
    > >> Argh!
    > >>
    > >> *Please* don't answer off-topic questions. The OP has already been
    > >> told to try comp.unix.questions, where his question is topical.
    > >>
    > >> If I hadn't happened to see your followup, people here might have been
    > >> left with the impression

    > >
    > > Yes. That would be why the second paragraph, which explicitly tells
    > > people to ask for responsible and correct advice in a newsgroup where
    > > Unix shells are on topic, was in that post.
    > >
    > > If the OP is willing to take the advice that is off-topic here, but not
    > > the advice to go find a more relevant newsgroup, he gets what he
    > > deserves. Darwin, have fun!

    >
    > Are you assuming that the OP is the only person reading your message?


    No. I'm assuming everyone else can read more than a single paragraph, as
    well. If they can't, what business do they have programming computers?

    Richard
    Richard Bos, Aug 11, 2006
    #14
  15. Guest

    sorry guys , that was a mistake , in future I will take care of it.

    Thanks for answering and clarifications.

    As I told I am new to the forum so , that was the reason I did that
    without proper understanding from my side.


    Richard Bos wrote:
    > Keith Thompson <> wrote:
    >
    > > (Richard Bos) writes:
    > > > Keith Thompson <> wrote:

    > > [...]
    > > >> Argh!
    > > >>
    > > >> *Please* don't answer off-topic questions. The OP has already been
    > > >> told to try comp.unix.questions, where his question is topical.
    > > >>
    > > >> If I hadn't happened to see your followup, people here might have been
    > > >> left with the impression
    > > >
    > > > Yes. That would be why the second paragraph, which explicitly tells
    > > > people to ask for responsible and correct advice in a newsgroup where
    > > > Unix shells are on topic, was in that post.
    > > >
    > > > If the OP is willing to take the advice that is off-topic here, but not
    > > > the advice to go find a more relevant newsgroup, he gets what he
    > > > deserves. Darwin, have fun!

    > >
    > > Are you assuming that the OP is the only person reading your message?

    >
    > No. I'm assuming everyone else can read more than a single paragraph, as
    > well. If they can't, what business do they have programming computers?
    >
    > Richard
    , Aug 11, 2006
    #15
  16. On 9 Aug 2006 23:49:09 -0700, "tinysisi" <> wrote:

    > wrote:
    > > Hi guys , I am new to this forum .
    > >
    > > can anybody plz tell me - "how can I run a c executable in some
    > > directory ,while the executable is in some other directory "
    > >
    > > I am new to unix and c ,so any pointers for help will be of great
    > > value.
    > >
    > > thanx in advance .
    > >
    > > vish

    > You can switch your pwd to the directory you want it to be in the
    > teminal.Then enter the executable's path to exec it.
    >

    <OT> Basically right but imprecise. Change the working directory of a
    command shell, and then use it to run the child. The terminal has
    nothing to do with it. It is possible, though ugly, to create a
    command shell that uses some other I/O and no terminal.

    > Another method is to execute it through a system call "exec(cmd,env)".
    > You can give the environment of the new process by the form param
    > "env".


    <OT> But this is wrong. First of all there is no actual 'exec' call;
    there are (now) 6 variants, of which only 2 take an (explicit)
    environment -- but even in those the environment can't change the wd,
    which is a separate OS-maintained process attribute.

    - David.Thompson1 at worldnet.att.net
    Dave Thompson, Aug 21, 2006
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vn
    Replies:
    2
    Views:
    447
  2. darrel

    PWD protecting individual files.

    darrel, Jun 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    332
    Shawn
    Jun 20, 2006
  3. Adam Smith
    Replies:
    2
    Views:
    376
    Adam Smith
    Dec 22, 2005
  4. absoft
    Replies:
    3
    Views:
    713
    dotnet dude
    Sep 6, 2006
  5. Thauhtopa
    Replies:
    4
    Views:
    286
    Thauhtopa
    Dec 7, 2004
Loading...

Share This Page