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

V

vishsid3

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
 
T

tinysisi

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".
 
V

vish

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 .
 
K

Keith Thompson

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.
 
A

amit

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!
 
I

Ian Collins

vish said:
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.
 
I

Ian Collins

amit said:
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.
 
K

Keith Thompson

amit said:
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.
 
R

Richard Bos

amit said:
Clearly.


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
 
A

Al Balmer

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.
 
K

Keith Thompson

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 &".)
 
R

Richard Bos

Keith Thompson said:
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
 
K

Keith Thompson

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?
 
R

Richard Bos

Keith Thompson said:
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
 
V

vishsid3

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.
 
D

Dave Thompson

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top