473,568 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding out the active Unix shell

Hi,

It's seems that csh and tcsh acts a bit different when handling
special characters in quotes.
i.e: if i'll supply my program with the following arguments: -winpath
"c:\\temp\\ "
tcsh will take it as -winpath "c:\temp\"
and csh will take it literally (with the double-slashes).

Is there a way for me to know what shell is currently running my
program, so I could fit a different code for each shell ?

Jun 7 '07 #1
21 2993
On 7 Jun, 08:22, Tom Gur <gur....@gmail. comwrote:
Hi,

It's seems that csh and tcsh acts a bit different when handling
special characters in quotes.
i.e: if i'll supply my program with the following arguments: -winpath
"c:\\temp\\ "
tcsh will take it as -winpath "c:\temp\"
and csh will take it literally (with the double-slashes).

Is there a way for me to know what shell is currently running my
program, so I could fit a different code for each shell ?
Not in the C language per se.

I suggest you ask the question in comp.unix.progr ammer.

Jun 7 '07 #2
"Tom Gur" <gu*****@gmail. comschrieb im Newsbeitrag
news:11******** **************@ o5g2000hsb.goog legroups.com...
Hi,

It's seems that csh and tcsh acts a bit different when handling
special characters in quotes.
i.e: if i'll supply my program with the following arguments: -winpath
"c:\\temp\\ "
tcsh will take it as -winpath "c:\temp\"
and csh will take it literally (with the double-slashes).

Is there a way for me to know what shell is currently running my
program, so I could fit a different code for each shell ?
What has this got to do with C and why do you post this question in
comp.lang.c?

the environment variable $SHELL might help. But you may also check in
comp.unix.progr ammer

Bye, Jojo
Jun 7 '07 #3
Tom Gur <gu*****@gmail. comwrites:
It's seems that csh and tcsh acts a bit different when handling
special characters in quotes.
[snip]

Ask in comp.unix.shell .

--
Keith Thompson (The_Other_Keit h) 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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 7 '07 #4
Maybe I wasn't clear.
I'm writing a C program (a server) that runs a Java program (an agent)
with some arguments.
The agent's shell is unknown, so I need to check, within my C code
what kind of shell runs on the account that runs the agent.
I was wondering whether you know any kind of function that can get
environment variables - so I'll be able to check the value of $SHELL
in the agent's machine.

Thanks

Jun 7 '07 #5
On 7 Jun, 10:07, Tom Gur <gur....@gmail. comwrote:
Maybe I wasn't clear.
Or maybe you weren't listening.
I'm writing a C program (a server) that runs a Java program (an agent)
with some arguments.
The agent's shell is unknown, so I need to check, within my C code
what kind of shell runs on the account that runs the agent.
I was wondering whether you know any kind of function that can get
environment variables - so I'll be able to check the value of $SHELL
in the agent's machine.
In the C language as such there won't be any such thing.

In the Unix APIs there may be an appropriate function but that's not
in the remit of this group.

You'll get better answers in a group relating to Unix - most likely
comp.unix.progr ammer.

<OffTopic>
Unix has getenv() but the $SHELL variable does not seem to be altered
if a new shell is launched.

And as to why anyone would use C shells, I despair...
</OffTopic>

Jun 7 '07 #6
In article <11************ *********@q75g2 000hsh.googlegr oups.com>,
Tom Gur <gu*****@gmail. comwrote:
>Maybe I wasn't clear.
I'm writing a C program (a server) that runs a Java program (an agent)
with some arguments.
The agent's shell is unknown, so I need to check, within my C code
what kind of shell runs on the account that runs the agent.
You're still not very clear. How are you running the program?
>I was wondering whether you know any kind of function that can get
environment variables - so I'll be able to check the value of $SHELL
in the agent's machine.
You can use the C function getenv(), but since you talk about "the
agent's machine" and "the account that runs the agent" it sounds
as if testing an environment variable in the server isn't going to
do much good. Perhaps you could have the server run a small program
on the other machine that does 'getenv("SHELL" )'.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 7 '07 #7
ma**********@po box.com wrote:
On 7 Jun, 10:07, Tom Gur <gur....@gmail. comwrote:
I was wondering whether you know any kind of function that can get
environment variables - so I'll be able to check the value of $SHELL
in the agent's machine.

In the C language as such there won't be any such thing.
Yesno.
In the Unix APIs there may be an appropriate function but that's not
in the remit of this group.

You'll get better answers in a group relating to Unix - most likely
comp.unix.progr ammer.

<OffTopic>
Not yet.
Unix has getenv()
Actually, that's an ISO C function, but...
but the $SHELL variable does not seem to be altered if a new shell is launched.
....C makes no guarantees about which variables are available, let alone
what they mean.

So the OP could easily use a C function, but _how_ he should use this
function does depend on the OS he uses (and frustratingly, could even
depend on the shell he uses... so to find out which shell he has, he
first has to find out which shell he has. Nice.)

Richard
Jun 7 '07 #8
ma**********@po box.com wrote, On 07/06/07 10:20:
On 7 Jun, 10:07, Tom Gur <gur....@gmail. comwrote:
>Maybe I wasn't clear.

Or maybe you weren't listening.
>I'm writing a C program (a server) that runs a Java program (an agent)
with some arguments.
The agent's shell is unknown, so I need to check, within my C code
what kind of shell runs on the account that runs the agent.
>I was wondering whether you know any kind of function that can get
environment variables - so I'll be able to check the value of $SHELL
in the agent's machine.

In the C language as such there won't be any such thing.

In the Unix APIs there may be an appropriate function but that's not
in the remit of this group.

You'll get better answers in a group relating to Unix - most likely
comp.unix.progr ammer.

<OffTopic>
Unix has getenv() but the $SHELL variable does not seem to be altered
if a new shell is launched.
getenv is actually part of the C standard, so the ability to use it to
access environment variable is topical here. However, what environment
variables are available and what they do is not topical, so you are
correct that comp.unix.progr ammer is a better place for the OP to ask.
And as to why anyone would use C shells, I despair...
</OffTopic>
Possibly because they like them :-)
--
Flash Gordon
Jun 7 '07 #9
On Thu, 07 Jun 2007 09:07:54 -0000, in comp.lang.c , Tom Gur
<gu*****@gmail. comwrote:
>Maybe I wasn't clear.
I'm writing a C program (a server) that runs a Java program (an agent)
with some arguments.
The agent's shell is unknown, so I need to check, within my C code
what kind of shell runs on the account that runs the agent.
The answer is unfortunatly still the same. You need to ask the
specialists in your os and /or compiler, since C itself has no
facilities for doing this. Most probably there's a function called
getenv() or something similar provided by your platform.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 7 '07 #10

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

Similar topics

2
5657
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info into a file with a 'ps' command. My question is "How to explicitly specify a Korn shell to be used by perl?" Eg of my perl code: ## Begin code...
22
2658
by: Tony Houghton | last post by:
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use "~/.bombz", in Windows something like "C:\Documents And Settings\<user>\Applicacation Data\Bombz". There are plenty of messages in the archives for this group about how to find the correct location in...
7
3535
by: kamkwokho | last post by:
Could any answer following questions as many as you can. ii) Write a C shell script convertmin which will read in a number, thought of as representing minutes, and print out the number of hours/minutes it represents so: $ convertmin Enter a number of minutes: 128
22
3044
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems so easy. Everything in the code either goes right to machine code, or links to a C library (often libc) or links to the kernel. Are there libc...
46
2483
by: dawn | last post by:
Hi all, I am now working on a C program under Unix. The requirement for the program is that: A file name is passed to program as a parameter. The program will Find files under a specified directory. The matched file must have the same content with the given file. It does not matter whether the filenames are the same. It is easy to find...
0
3034
by: Aashif | last post by:
I want to call Unix Shell script which is available in other Server (Unix server) from windows application using C#. Currently the shell script runs the C program but the GUI is not good, So I want to create GUI in C# windows application and call that C program using Shell script so first I have to call unix shell script from C#. Please guide me...
9
78257
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell script and export the result to a file. Any code snippet on this will be helpful.
2
1586
by: frikk | last post by:
Hey everyone, (Sorry about the first message if it made it - i got cut off early). I have a homework problem for my Operating Systems class. I am supposed to use a command such as "ps -aux" and return "N number of users, M number of processes". How am I to go about doing this? I am not very familiar with string parsing in c++, is this the...
2
2686
by: zw | last post by:
Hi I have 2 unix boxes. In each box, I have a unix shell script that captures certain statistics to a file of the unix box. During the run of the 2 shell scripts, I need a common timestamp for both. I'm thinking of writing a C# app to issue commands every few mins to these shell scripts and capture the statistics back to a file in a...
0
7913
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7659
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.