Java or C for creating a unix shell?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Java or C for creating a unix shell?
# 1  
Old 09-09-2008
Bug Java or C for creating a unix shell?

Hi,

Great to find this forum!
I'm a complete newbie to unix, and am having a hard time finding my way around.
Firstly, I've been reading something about c shell programming being one tenth the size of c programming done on unix.....I couldn't figure what that meant, but there were two different kind of syntaxes shown.
Searching on the net also showed that Java could be used for creating a unix shell. Is that true? I mean, if I want to create a shell of my own, will Java be powerful enough to start and stop processes or create new processes etc?

Thanks.
# 2  
Old 09-09-2008
For performance reasons you'd be ill advised to implement a shell in Java, in my opinion. However, if portability is very important for you, there may be an argument to do so. I see no technical reason that would prevent you from doing so.

C shell programming (or scripting) and C programming are very different things, I'm not sure why you'd even compare them like that? C is a compiled language that generates fast, efficient binaries. C shell is a command/script interpreter, and not a choice of shell that I would personally recommend.
# 3  
Old 09-09-2008
Thanks Annihilannic!
Performance is important to me. I guess C would be better then.

ok, so shell scripting is done in C? I was under the impression that it was with using those echo commands etc like using batch files in MSDOS.

The point is, that when I was working on an old 286 computer (long time ago) which had only MSDOS, I had created a QBASIC program which pretty much acted like a GUI for MSDOS. It used batch files to execute DOS commands, while BASIC provided a user friendly interface.
I was quite happy to know that a UNIX shell can also be created with C, but knowing nothing about it, I didn't know where to start.

Could you give me some pointers as to where to refer for info on this? Do I just write a C program to imitate a unix shell and if I call it shell.exe, and run it from the unix prompt, will it actually behave like a real unix shell? Will I be able to control processes from this shell I create?
# 4  
Old 09-09-2008
Quote:
Originally Posted by sdsd
ok, so shell scripting is done in C? I was under the impression that it was with using those echo commands etc like using batch files in MSDOS.
Err... no. Shell scripting is done in the language of whatever command shell you choose to use, whether it happens to be MS-DOS (COMMAND.COM), C shell (/usr/bin/csh), Korn shell (/usr/bin/ksh), bash, zsh, sh, .... the list goes on. Shell scripting is a generic term.

C shell just happens to be a shell that uses some constructs that are similar to the C programming language, which may be convenient for a C programmer, however (as you have demonstrated) it causes some confusion, and doesn't necessarily result in the most well defined scripting language.

The shells themselves are for the most part compiled C binaries. I really don't think you would be adding much value by writing yet another shell, unless of course it is purely for your own educational purposes. The common Unix shells are generally powerful enough to allow you to customise them by using scripting.
# 5  
Old 09-12-2008
Yeah, it's just for learning how these shells work. Been a windows user for long...heard unix gives more power to the programmer. Thanks! Smilie
# 6  
Old 09-20-2008
I had the idea that I'd have to keep taking command line arguments from the user, just like the command prompt of bash keeps accepting commands.
But in order to take command line inputs, I'd have to repeatedly send values to main() right?
Is it possible/wise to do that or do I just create a while loop which keeps accepting strings?
# 7  
Old 09-21-2008
It's not wise to do that, main() should only be called once. Just create a while loop.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to execute a unix shell script from a java program

Hi All, well , i am facing this problem.. i have tried a few sample codes but there isn't any solution . could anyone please give a sample code as of how to do this... Please see the below details...and read the details carefully. I have written some code, logic is 1)from... (4 Replies)
Discussion started by: aish11
4 Replies

2. Shell Programming and Scripting

Calling Java Method from UNIX using shell script

Hi All, I need to call a java method from a shell script. I know we can use the command java ClassName to call the main method in it. But I need to call another method that is there in the class and pass an email to it. Can I use java ClassName.MethodName(email) Any help will be... (4 Replies)
Discussion started by: RahulK
4 Replies

3. Programming

Creating a basic UNIX shell script for chatting

Hey guys, This is quite simply what I'm trying to make: A program that runs in a UNIX terminal that you can output text messages to from another machine. These text messages would be prepended with a customized prompt. I'd also like to have the window spew out random dumps of flavor text not... (1 Reply)
Discussion started by: AcerAspirant
1 Replies

4. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

5. Programming

Creating email account prgramatically + java ?

Dear Friend, I am working on java application which requires that after successful registration an email account is created (say username@mydomain.com) for user. Is is possible to create e-mail account programatically ? Enviornment - CentOs, Tomcat Web server. CPanel is available, but... (0 Replies)
Discussion started by: reckless_jack
0 Replies

6. Shell Programming and Scripting

Creating a command history feature in a simple UNIX shell using C

I'm trying to write a history feature to a very simple UNIX shell that will list the last 10 commands used when control-c is pressed. A user can then run a previous command by typing r x, where x is the first letter of the command. I'm having quite a bit of trouble figuring out what I need to do, I... (2 Replies)
Discussion started by: -=Cn=-
2 Replies

7. Shell Programming and Scripting

Opening a UNIX shell in Java

Hi, I need to simulate the machine's native shell (sh), for that I open up a UNIX shell in my Java program. My code works fine with windows shell ('cmd') but with unix ('sh') I failed to retrieve the machine's prompt. I believe that the issue is unix-related and that the process I launched has... (2 Replies)
Discussion started by: guyi
2 Replies

8. Shell Programming and Scripting

Unix Shell script vs Java

Members, I been faced with an issue where i have to sale my project against JAVA.would like to know more on the strong point of shell script (bash shell) over java.I have a very limited knowledge on java.is there anyone who has worked on java and shell scripting in both and really been able to... (13 Replies)
Discussion started by: navojit dutta
13 Replies

9. Programming

exit status running java classpath in unix shell

I have a java classpath running inside of a unix shell script. During my testing it will error with lines that show an example like this below. java.io.FileNotFoundException error at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:129), ... (2 Replies)
Discussion started by: mmcds
2 Replies
Login or Register to Ask a Question