Write a java program that contains a shell script
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Write a java program that contains a shell script

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    4

    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...

  2. #2
    Join Date
    Aug 2011
    Location
    West Yorkshire, U.K.
    Posts
    54

    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

  3. #3
    Join Date
    Feb 2013
    Posts
    4

    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...

  4. #4
    Join Date
    Aug 2011
    Location
    West Yorkshire, U.K.
    Posts
    54

    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?

  5. #5
    Join Date
    Feb 2013
    Posts
    4

    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...

  6. #6
    Join Date
    May 2009
    Location
    Surrey, UK
    Posts
    285

    Re: Write a java program that contains a shell script

    Quote Originally Posted by jemvision View Post
    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).

    Quote Originally Posted by jemvision View Post
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center