473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Alignment of command prompt output of remote server

12
Hi,

My program is access the remote system's command prompt through C# program. I can do it. But problem is alignment of that output.
can any one give idea to align that output ?.


here is my code......................



try
{
SshShell ssh1 = new SshShell(host,user,pass);

SshStream ssh = new SshStream(host, user, pass);
Console.WriteLine("------Connecting...");
ssh1.Connect();
Console.Write("OK");
Console.WriteLine();
//ssh.Prompt ="$";

ssh1.RemoveTerminalEmulationCharacters = true;
Console.Write(ssh1.Expect("$"));
//ssh1.Expect("$");
while (true)
{
Console.Write("Ent the cmd:");
string command = Console.ReadLine();
if (command.ToLower().Equals("exit"))
break;
ssh1.WriteLine(command);
string out1 = ssh1.Expect(">");
out1 = out1.Replace(" ", "\n ");
out1 = "\n" + out1;
Console.WriteLine(out1);
//Console.WriteLine(ssh1.Expect(">"));

}
ssh1.Close();
ssh.Close();
Console.WriteLine("Connection closed.");

}
Oct 31 '07 #1
10 2771
Plater
7,872 Expert 4TB
What do you mean by alignment?
Oct 31 '07 #2
vel
12
What do you mean by alignment?


Thanks for your reply.


The output should be appear as same that of command prompt window output(line by line). eg:1) First Line......
2)Second Line.......and so on
Now it prints
as shown below.
eg: 1)First Line......2)Second Line.......3) and so on...

it use the full length of the output screen.after that only it comes to 2nd line..
Nov 1 '07 #3
vel
12
Hi,


when we use dir,ipconfig command the outputs are in multi line. Is it ?
i have to align that output as it showing in command prompt.
Nov 1 '07 #4
Plater
7,872 Expert 4TB
newlines are "\r\n", if that helps.
Although Console.WriteLine() should have created a "newline" for you. Odd
Nov 1 '07 #5
r035198x
13,262 8TB
Try reading the response with

Expand|Select|Wrap|Line Numbers
  1.  String output = ssh1.ReadResponse();
Nov 1 '07 #6
vel
12
thanks for your reply.
Ya, I tried it.


I need the Output in the following format.

---------------------------------------------------------------
C:\Documents and Settings\udhaya.k>dir
Volume in drive C has no label.
Volume Serial Number is A421-E76F

Directory of C:\Documents and Settings\udhaya.k

11/22/2006 12:04 PM <DIR> .
11/22/2006 12:04 PM <DIR> ..
02/09/2007 12:18 PM 175 .jlogon9
03/05/2007 06:11 PM 1,403 .isqlHistory9
10/24/2007 05:30 PM 1,846 .bookmarks
06/02/2006 11:10 AM <DIR> Start Menu
12/15/2006 12:50 PM <DIR> My Documents 19 File(s) 258,099 bytes
15 Dir(s) 12,946,948,096 bytes free
------------------------------------------------------------------------------------------


But in console Application it printed in following format:
--------------------------------------------------------------------------------
C:\Documents and Settings\udhaya.k>dirVolume in drive C has no label.Volume Serial Number is A421-E76 Directory of C:\Documents and Settings\udhaya.k11/22/2006 12:04 PM <DIR> .11/22/2006 12:04 PM <DIR> ..02/09/2007 12:18 PM 175 .jlogon903/05/2007 06:11 PM 1,403 .isqlHistory910/24/2007 05:30 PM 1,846 .bookmarks06/02/2006 11:10 AM <DIR> Start Menu
12/15/2006 12:50 PM <DIR> My Documents 19 File(s) 258,099 bytes
15 Dir(s) 12,946,948,096 bytes free
---------------------------------------------------------------------------------------------------------------


Now can you get it off my problem?. The stream prints the output continuously.



newlines are "\r\n", if that helps.
Although Console.WriteLine() should have created a "newline" for you. Odd
Nov 2 '07 #7
vel
12
thanks for your reply.
Ya, I tried it.


I need the Output in the following format.This is the cmd prompt output.

---------------------------------------------------------------
C:\Documents and Settings\udhaya.k>dir
Volume in drive C has no label.
Volume Serial Number is A421-E76F

Directory of C:\Documents and Settings\udhaya.k

11/22/2006 12:04 PM <DIR> .
11/22/2006 12:04 PM <DIR> ..
02/09/2007 12:18 PM 175 . jlogon9
03/05/2007 06:11 PM 1,403 .isqlHistory9
10/24/2007 05:30 PM 1,846 .bookmarks
06/02/2006 11:10 AM <DIR> Start Menu
12/15/2006 12:50 PM <DIR> My Documents
19 File(s) 258,099 bytes
15 Dir(s) 12,946,948,096 bytes free
------------------------------------------------------------------------------------------


But in console Application it printed in following format:
--------------------------------------------------------------------------------
C:\Documents and Settings\udhaya.k>dirVolume in drive C has no label.Volume Serial Number is A421-E76 Directory of C:\Documents and Settings\udhaya.k11/22/2006 12:04 PM <DIR> .11/22/2006 12:04 PM <DIR> ..02/09/2007 12:18 PM 175 .jlogon903/05/2007 06:11 PM 1,403 .isqlHistory910/24/2007 05:30 PM 1,846 .bookmarks06/02/2006 11:10 AM <DIR> Start Menu
12/15/2006 12:50 PM <DIR> My Documents 19 File(s) 258,099 bytes
15 Dir(s) 12,946,948,096 bytes free
---------------------------------------------------------------------------------------------------------------


Now can you get it off my problem?. The stream prints the output continuously.
Please Try my code.


newlines are "\r\n", if that helps.
Although Console.WriteLine() should have created a "newline" for you. Odd
Nov 2 '07 #8
r035198x
13,262 8TB
thanks for your reply.
Ya, I tried it.


I need the Output in the following format.This is the cmd prompt output.

---------------------------------------------------------------
C:\Documents and Settings\udhaya.k>dir
Volume in drive C has no label.
Volume Serial Number is A421-E76F

Directory of C:\Documents and Settings\udhaya.k

11/22/2006 12:04 PM <DIR> .
11/22/2006 12:04 PM <DIR> ..
02/09/2007 12:18 PM 175 . jlogon9
03/05/2007 06:11 PM 1,403 .isqlHistory9
10/24/2007 05:30 PM 1,846 .bookmarks
06/02/2006 11:10 AM <DIR> Start Menu
12/15/2006 12:50 PM <DIR> My Documents
19 File(s) 258,099 bytes
15 Dir(s) 12,946,948,096 bytes free
------------------------------------------------------------------------------------------


But in console Application it printed in following format:
--------------------------------------------------------------------------------
C:\Documents and Settings\udhaya.k>dirVolume in drive C has no label.Volume Serial Number is A421-E76 Directory of C:\Documents and Settings\udhaya.k11/22/2006 12:04 PM <DIR> .11/22/2006 12:04 PM <DIR> ..02/09/2007 12:18 PM 175 .jlogon903/05/2007 06:11 PM 1,403 .isqlHistory910/24/2007 05:30 PM 1,846 .bookmarks06/02/2006 11:10 AM <DIR> Start Menu
12/15/2006 12:50 PM <DIR> My Documents 19 File(s) 258,099 bytes
15 Dir(s) 12,946,948,096 bytes free
---------------------------------------------------------------------------------------------------------------


Now can you get it off my problem?. The stream prints the output continuously.
Please Try my code.
So ssh1.ReadResponse() did not work as well?
Nov 2 '07 #9
Plater
7,872 Expert 4TB
Are you removing your line breaks? Where are the "\r\n" ?
Nov 2 '07 #10
vel
12
Are you removing your line breaks? Where are the "\r\n" ?

Oh! Thanks for your Help....
and I tried that too...
but i not coming...Anyway
I completed that task.....
Nov 5 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: René | last post by:
Hello group, I have a question about a script i use. The function of the script is to dynamically write an ftp script and execute this with dos ftp.exe . This script always worked on a Windows...
6
by: Paul Deverson | last post by:
I'm a newbie to MySQL and am really confused about when I should be using the Command Line Client and when the DOS prompt. I'm using Windows XP and I've just installed MySQL 4.1.10. I can use...
2
by: Mustaq | last post by:
Hi, I have an application in VB.NET which runs from command prompt, I need output message in the same command prompt window, Example D:\Mustaq\ORC\Orc 3.7\Insertor\Insertor\bin>insertor.exe ...
3
by: Billy Cormic | last post by:
Hello, I would like to write a windows application that can get the IP address of the computer the appliation is installed on. Then the program should ftp a file to another computer. I have no...
16
by: diffuser78 | last post by:
I want to write a python program and call OS specific commands in it. So basically, instead of typing in on the command line argument I want to have it in a python program and let it do the action....
0
by: maykil ceksin | last post by:
Hi, Is there anyone knows which user profile is using by IIS while running an DOS application within asp with wshell.run command. To describe my problem clear; I'm using a DOS command and...
2
by: Gil_H | last post by:
Hi, I'm trying to run a script over unix on a remote machine. In order to automate it, the procedure requests the following: 1. Using SSH connection. 2. Operating a command on the remote...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
4
by: sdanda | last post by:
Hi, I am working on C# windows applications.What i want to do is, I want to Redirect the output from Command Prompt to the Rich Text Box, Actually i am unable to read the entire output of the comman...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.