SSH.ReadText
------------

Reads bytes from channel and returns them as text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SSH](component_SSH.md) | [6.3](newinversion63.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SSH.ReadText"; SSH { ; Length; Encoding; Stream } ) 

**MBS**( **"SSH.ReadText";** /\* Reads bytes from channel and returns them as text. \*/  
**$SSH**; /\* The SSH session reference number from the plugin. \*/   
**$Length**; /\* Optional; Maximum number of bytes to read.e.g. 10 \*/   
**$Encoding**; /\* Optional; The text encoding for result.   
Default is UTF-8.e.g. UTF8 \*/   
**$Stream**) /\* Optional; Which stream to read.  
Can be stdout or stderr.   
Stdout is default if parameter is empty or missing.e.g. "StdOut" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| SSH | The SSH session reference number from the plugin. | $ssh |  |
| Length | Maximum number of bytes to read. | 10 | Optional |
| Encoding | The text encoding for result.    Default is UTF-8.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | UTF8 | Optional |
| Stream | Which stream to read.   Can be stdout or stderr.    Stdout is default if parameter is empty or missing. | "StdOut" | Optional |

### Result

Returns text or error message.

### Description

Reads bytes from channel and returns them as text.  
The text returned may be shorter than length bytes.  
### Examples

Read all text:

 # We read text in several chunks until no new text is coming any more:   
Set Variable \[$text ; Value:""\]  
Loop  
 Pause/Resume Script \[Duration (seconds): ,1\]  
 # Read some text:  
 Set Variable \[$newtext ; Value:MBS ( "SSH.ReadText"; $ssh ; 10000; "UTF8" )\]  
 If \[MBS ("iserror") = 0\]  
 If \[Length($newText ) &gt; 0\]  
 Set Variable \[$text ; Value:$text &amp; $newText \]  
 End If  
 Exit Loop If \[Length($newText ) = 0\]  
 End If  
End Loop  
Set Field \[SSH::Result ; $text \]  
### See also

- [IsError](IsError.md)
- [SSH.Connect](SSHConnect.md)
- [SSH.Execute](SSHExecute.md)
- [SSH.New](SSHNew.md)
- [SSH.ReadHex](SSHReadHex.md)

### Example Databases

- [Network/SSH](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/SSH.shtml#1ScriptAnchor_)

This function checks for a license.

Created 29th May 2016 , last changed 27th May 2017

  
[SSH.ReadHex](SSHReadHex.md) - [SSH.Release](SSHRelease.md)

[HTML Version](SSHReadText.shtml)