473,395 Members | 1,471 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,395 software developers and data experts.

System cmds

How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?
thanks

Nov 14 '05 #1
6 1989
in comp.lang.c i read:
How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?


build the string you want first. sprintf may be useful to you for that.

--
a signature
Nov 14 '05 #2
Profetas wrote:
How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?
thanks

You question is OS specific, and as I have been told,
is off topic for this list, which appears to dig deep
into ISO C99:

http://www.open-std.org/jtc1/sc22/wg14/

which is OS independent.

Nevertheless, if you are talking about a executing a file,
here's the best example I could find for Unix:

http://www.gnu.org/software/libc/man...tion%20Example

Read up from the example. It explains all the types and functions.

If you want to learn more about your computer, mudge wrote a great
article on creating a buffer overflow that shows the use of an exec()
function and then converts it to assembly and finally to op codes. It
a great read if you want to learn more about how instructions are executed.

Here's a link to that article:

http://www.insecure.org/stf/mudge_bu..._tutorial.html

I do not code windows, so I don't have a clue as to how to help you there.

Cheers,

Brian
Nov 14 '05 #3
"those who know me have no need of my name" <no****************@usa.net>
wrote in message news:m1*************@usa.net...
in comp.lang.c i read:
How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?
build the string you want first. sprintf may be useful to you for that.


system() probably won't do what you want it to do either. The system()
function forks a child process, which I believe then runs your shell, which
then runs your command such as "cd". This will result in no change of
working directory for the parent process (which is probably what you're
trying to achieve). Try looking for the chdir() function in the standard C
library, this probably does do what you want.

--
a signature

Nov 14 '05 #4
"Kieran Simkin" <ki****@digital-crocus.com> writes:
"those who know me have no need of my name" <no****************@usa.net>
wrote in message news:m1*************@usa.net...
in comp.lang.c i read:
How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?


build the string you want first. sprintf may be useful to you for that.


system() probably won't do what you want it to do either. The system()
function forks a child process, which I believe then runs your shell, which
then runs your command such as "cd". This will result in no change of
working directory for the parent process (which is probably what you're
trying to achieve). Try looking for the chdir() function in the standard C
library, this probably does do what you want.


The terms "fork", "child process", "shell", and "working directory"
are all system-specific. There is no chdir() function in the standard
C library, though there may be such a function in some system-specific
(POSIX?) library.

<OT>I think your answer would be correct in comp.unix.programmer.</OT>

--
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.
Nov 14 '05 #5

"tweak" <xb**********@cox.net> wrote in message
How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?

You question is OS specific, and as I have been told,
is off topic for this list, which appears to dig deep
into ISO C99:

Actaully this one is on-topic. The details of the the "cd" command are
off-topic, of course, it may be a compact disk burner or a dc current
inverter for all we care, but how to pass a command line to "system" is
topical enough.
Nov 14 '05 #6
"Malcolm" <ma*****@55bank.freeserve.co.uk> writes:
"tweak" <xb**********@cox.net> wrote in message
How can I use shell cmds with vars?
I would like to execute
system("cd var_path");
where the var_path is a variable that has the path.
is there any other way that enables me to use vars?

You question is OS specific, and as I have been told,
is off topic for this list, which appears to dig deep
into ISO C99:

Actaully this one is on-topic. The details of the the "cd" command are
off-topic, of course, it may be a compact disk burner or a dc current
inverter for all we care, but how to pass a command line to "system" is
topical enough.


Agreed, but the question of whether system("cd var_path") will do what
you expect it to is system-specific and off-topic. (On Unix-like
systems, it will have no effect on the current process; on other
systems, I have no ides.)

--
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.
Nov 14 '05 #7

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

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
by: Ty Moffett | last post by:
I'm using a queue to hold a series of strings that are complete command line arguments to start the silent/unattended installation of various pieces of software. Here is some sample code. 1 Dim...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.