Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1008417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:46:04+00:00 2026-05-16T08:46:04+00:00

I need to run an .sh file and get its output. I need to

  • 0

I need to run an .sh file and get its output. I need to see the setup of the file as well.

The .sh file simply runs a java app through terminal.

Any ideas? I’m truly stuck on this…..

Elijah

The server.sh file:

echo Starting Jarvis Program D.
ALICE_HOME=.
SERVLET_LIB=lib/servlet.jar
ALICE_LIB=lib/aliceserver.jar
JS_LIB=lib/js.jar

# Set SQL_LIB to the location of your database driver.
SQL_LIB=lib/mysql_comp.jar

# These are for Jetty; you will want to change these if you are using a different http server.
 HTTP_SERVER_LIBS=lib/org.mortbay.jetty.jar

 PROGRAMD_CLASSPATH=$SERVLET_LIB:$ALICE_LIB:$JS_LIB:$SQL_LIB:$HTTP_SERVER_LIBS
 java -classpath $PROGRAMD_CLASSPATH -Xms64m -Xmx128m org.alicebot.server.net.AliceServer $1

My current code:

NSTask *server = [NSTask new];
[server setLaunchPath:@"/bin/sh"];
[server setArguments:[NSArray arrayWithObject:@"/applications/jarvis/brain/server.sh"]];

NSPipe *outputPipe = [NSPipe pipe];
[server setStandardInput:[NSPipe pipe]];
[server setStandardOutput:outputPipe];
[server launch];


NSMutableString *outputString = [NSMutableString string];
while ([outputString rangeOfString:@"Jarvis>"].location == NSNotFound) {
    [outputString appendString:[[[NSString alloc] initWithData:[[outputPipe fileHandleForReading] readDataToEndOfFile] encoding:NSUTF8StringEncoding] autorelease]];
    NSRunAlertPanel(@"", outputString, @"", @"", @"");

}

The NSRunAlertPanel is just for checking the output. Now my code is freezing and not even getting to the alertpanel.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:46:05+00:00Added an answer on May 16, 2026 at 8:46 am

    See answer to this question.

    There are a couple of things that should be fixed in your script:

    • The script should begin with a
      shebang. Also make sure that the
      script has its executable bit set.
    • Because the environment variables are set up relative to the shell script directory, you need to make sure that the script directory is the current directory.
    • You need to export the environment variables that should be visible to the Java process.
    • In the last line you can use exec to replace the shell process with the Java executable that runs Jetty.

    Here is a revised version of your script:

    #!/bin/sh
    echo Starting Jarvis Program D.
    cd "`dirname \"$0\"`"
    export ALICE_HOME=.
    export SERVLET_LIB=lib/servlet.jar
    export ALICE_LIB=lib/aliceserver.jar
    export JS_LIB=lib/js.jar
    
    # Set SQL_LIB to the location of your database driver.
    export SQL_LIB=lib/mysql_comp.jar
    
    # These are for Jetty; you will want to change these if you are using a different http server.
    export HTTP_SERVER_LIBS=lib/org.mortbay.jetty.jar
    
    export PROGRAMD_CLASSPATH=$SERVLET_LIB:$ALICE_LIB:$JS_LIB:$SQL_LIB:$HTTP_SERVER_LIBS
    exec java -classpath $PROGRAMD_CLASSPATH -Xms64m -Xmx128m org.alicebot.server.net.AliceServer $1
    

    Invoking the shell script in Objective-C with multiple arguments:

    NSTask *server = [NSTask new];
    [server setLaunchPath:@"/bin/sh"];
    [server setArguments:[NSArray arrayWithObjects:@"/applications/jarvis/brain/server.sh", @"argument", nil]];
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a shell command and get its output in clickable
I can run a bat file in java, I can also get it to
I need to run an executable JAR file in multiple threads/cores. The JAR file
I need to run a script that will generate the projects.list file when a
I'm using CScript to run a VBScript file, and I need to pass a
I need to run a script and have access to the default stdin (terminal
I need to run an external application from within my Java code. I can
I'm trying to get libarchive working in my Rails app. Specifically, I need to
i need run code that will create a database and populate tables. i am
I need run ts:reindex when smth add in model or destroy from model. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.