-
February 12th, 2013, 04:04 AM
#1
Write a java program that contains a shell script
hey folks...
request your help...
Write a java program that contains a shell script which will point to the local directory (current working directory ) and a create a folder there.
When I run the java program using the IDE, it should create a folder in my current working directory,,,
but again the java code must have the shell script to do this task..
please help...
-
February 12th, 2013, 04:12 AM
#2
Re: Write a java program that contains a shell script
http://stackoverflow.com/questions/5...from-java-code
But not generally a good idea because it ties your (portable) java application to unix/linux systems.
Alternatively, use the API functions
http://stackoverflow.com/questions/4...folder-in-java
-
February 12th, 2013, 04:17 AM
#3
Re: Write a java program that contains a shell script
Yea.. Its true that its not a good idea...
but it was an assigned task to me... so I have to do it
Thanks Alex for your response..
But i tried the code mentioned on
http://stackoverflow.com/questions/5...from-java-code
Doesnt seem to work...
-
February 12th, 2013, 05:41 AM
#4
Re: Write a java program that contains a shell script
Was there an error? Did the program print a stack trace? Does the shell script work when you invoke it by hand rather than from the java program?
-
February 13th, 2013, 01:42 AM
#5
Re: Write a java program that contains a shell script
yea.. it says it cant recognise /bin/ksh .
its obvious because I cant execute a shell command from windows...
could someone please post in a complete working program...
-
February 13th, 2013, 05:19 AM
#6
Re: Write a java program that contains a shell script
Originally Posted by jemvision
yea.. it says it cant recognise /bin/ksh .
its obvious because I cant execute a shell command from windows...
If you are running your program in Windows you need to use cmd for the shell instead of ksh. You also need to pass /C as an option to cmd so it runs the command (ie your shell script) and terminates, otherwise it will keep running, waiting for more commands (as when you open a DOS window).
Originally Posted by jemvision
could someone please post in a complete working program...
Nope, that's your homework for you to do. It was given to you so you can practice what you have been taught. If we give you a complete working program it would be like cheating and you would learn nothing. We can help you through any issues you may found, but it's going to be better for you to do your homework yourself.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|