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 4587172
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:44:32+00:00 2026-05-21T21:44:32+00:00

Hey all, Ive been using a new SHH library to send commands to a

  • 0

Hey all, Ive been using a new SHH library to send commands to a unix server and its been working great for me. It sends normal commands just fine and recives the proper responses. However, I seem to be running into an issue when I try to use it to run a custom script (not a shell script, but a file that contains another command and has arguments)

Ive tried several ways to get this to work.

On the unix server itself the following commands work perfectly and do what they are intended:

  • cd script; script.oi someArg someArg – WORKS
  • csh -c “cd script; script.oi someArg someArg” – ALSO WORKS
  • cd /users/bin/script; script.oi someArg1 someArg 2 – WORKS
  • csh -c “cd /users/bin/script; script.oi someArg1 someArg 2” – WORKS
  • /users/bin/script/script.oi someArg1 someArg2 – WORKS

However, in the code I have tried the following:

string command = string.Format("csh -c \"cd script; script.oi {0} {1}\"", arg1, arg2); - DOES NOT WORK
string command = string.Format("cd script; script.oi {0} {1}", arg1, arg2); - DOES NOT WORK
string command = string.Format("cd /users/bin/script; script.oi {0} {1}", arg1, arg2); - DOES NOT WORK 
string command = string.Format("csh -c \"cd /users/bin/script; script.oi {0} {1}\"", arg1, arg2); - DOES NOT WORK 
string command = string.Format("/users/bin/script/script.oi {0} {1}", arg1, arg2); - DOES NOT WORK

So to me it seems like something else is going on. I did try the following:

string command = string.Format("csh -c \"ls\"", arg1, arg2);` - WORKS
string command = string.Format("ls", arg1, arg2);` - WORKS

It looks like it has to do with the fact that Im trying to run a custom script, or maybe some silly setting I’ve forgotten. Let me know if you need anymore details.

EDIT: By DOES NOT WORK, I mean that the result that is returned to the C# is supposed to say some stuff, but the result is blank. Additionaly, the script sends a TIBCO Rendevous message which eventually adds an entry to a DB, which is not showing up. When I say WORKS, I mean that the entry is showing up in the DB.

  • 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-21T21:44:32+00:00Added an answer on May 21, 2026 at 9:44 pm

    Well, I figured it out. Turns out the script was running a command that is known to the unix server via being added to the unix eviroment variables. When just using the standard way to send commands in SSH.NET, the enviroment variables are not imported (which is why you are able to send normal commands like ls, grep, cat, ect, but not this one).

    The fix was to use the libraries SSH shell functionality because it does import the enviroment variables, therefore it knows what that command in the script is and is able to run it. For those using this great library (which is still be activily developed, always a plus) I have included below example SSH.NET Shell code.

    PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("some IP", "user", "pass");
    
    try
    {
        using (var client = new SshClient(connectionInfo))
        {
            client.Connect();
            var input = new MemoryStream(Encoding.ASCII.GetBytes(command));
            var shell = client.CreateShell(input, Console.Out, Console.Out, "xterm", 80, 24, 800, 600, "");
            shell.Stopped += delegate(object sender, EventArgs e)
            {
                Console.WriteLine("\nDisconnected...");
            };
            shell.Start();
            Thread.Sleep(1000);
            shell.Stop();
            client.Disconnect();
        }   
    }
    catch (Exception ex)
    {
        // Exception stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I hope you can help me. Ive been working in development mode all
Hey all, have been working on designing a new database for work. They have
(I'm also asking this on the OpenRasta google group) Hey all, I've been using
Hey all. I have a server written in java using the ServerSocket and Socket
Hey all, i've been working on this small project in XNA the goal is
Hey all, I've been messing around with this awesome library on my *nix box,
Hey all i've been using some filters. Not all of them seem to work
Hey guys, ive been working on this drop down for wayyy to long now.
Hey all. We're sending quite a few emails (around 23k) using IIS6 SMTP service
Hey all, I've been reading up on the best way to implement the GetHashCode()

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.