473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

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 '06 #1
15 1500
vi******@gmail.com 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".

Aug 10 '06 #2
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:
vi******@gmail.com 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".
Aug 10 '06 #3
vi******@gmail.com 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) ks***@mib.org <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.
Aug 10 '06 #4

vi******@gmail.com 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!

Aug 10 '06 #5
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.
Aug 10 '06 #6
amit wrote:
vi******@gmail.com 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.
Aug 10 '06 #7
"amit" <am*********@gmail.comwrites:
vi******@gmail.com 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) ks***@mib.org <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.
Aug 10 '06 #8
"amit" <am*********@gmail.comwrote:
vi******@gmail.com 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
Aug 10 '06 #9
On 10 Aug 2006 01:17:55 -0700, "vish" <vi******@gmail.comwrote:
>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
Aug 10 '06 #10
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
"amit" <am*********@gmail.comwrote:
>vi******@gmail.com 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) ks***@mib.org <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.
Aug 10 '06 #11
Keith Thompson <ks***@mib.orgwrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
"amit" <am*********@gmail.comwrote:
vi******@gmail.com 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
Aug 11 '06 #12
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
Keith Thompson <ks***@mib.orgwrote:
[...]
>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) ks***@mib.org <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.
Aug 11 '06 #13
Keith Thompson <ks***@mib.orgwrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
Keith Thompson <ks***@mib.orgwrote:
[...]
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 '06 #14
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 <ks***@mib.orgwrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
Keith Thompson <ks***@mib.orgwrote:
[...]
>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 '06 #15
On 9 Aug 2006 23:49:09 -0700, "tinysisi" <sh******@gmail.comwrote:
vi******@gmail.com 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.
<OTBasically 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".
<OTBut 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
Aug 21 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: David Lozzi | last post by:
Hello all, I am deploying many ASP apps and many of them are onto client internal servers. I was wondering if there was an option to compile my entire ASP project into an installation executable...
2
by: mhk | last post by:
Hi , i am writing a c language program in Unix to see the executable files in a directory and it works if the directory is current but if i change to another directory than current directory...
3
by: redneon | last post by:
It it possible to the directory that the executable is running from? At the moment I've been trying to use... Directory.GetCurrentDirectory(); ....but the problem with this is that if I have...
3
by: hpark2_1999 | last post by:
Hi! I know how easy it is to create an NT services using .net framework (using Visual Studio 2003). Here is my problem. I came across a situation where I would like to run 2 instances of a...
5
by: nylyst | last post by:
I've run into a rather strange situation, and can't seem to find any details on why this would even be happening, so here goes: I've created an app to force users to update their pcAnywhere...
7
by: patrik.kahari | last post by:
Is there a c++ function similar to getcwd that does not give you the working directory but the directory or path of the currently running executable? I need this because im porting a game that...
6
by: Scubadude | last post by:
Hi, I'm new to perl and have run into some roadblocks while trying to run tutorials. I have installed Apache v2.2.3 I have installed ActivePerl v6.6.1.638 I have installed php v5.2.0 I am...
3
by: Jeffrey Froman | last post by:
Hello All, I have two python versions installed, one in /usr/bin, and one in /usr/local/bin. However, when invoking python without a full path, I get the wrong executable with the right...
2
by: NasirMunir | last post by:
I am trying to run an executable using shell. The executable look for certain files in the same directory and then run on those files. My problem: I have created a form which asks from the user to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.