Function: SSH Command Put File

by Simon Sparks · 24 March 2026

To use this function add it to the class library file named PluginSSHService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: PluginSSHService.ts

Description: Orchestrator Function to Put a File via SSH

Public Function: putFile

publicputFile(strHostFQDN:string,strUsername:string,strPassword:string,strRemoteFilePath:string,strLocalFileName:string,strContent:string,intPort:number=22):boolean{
try{
letstrLocalFilePath:string=`/var/run/vco/${strLocalFileName}-${(newDate()).getTime()}.txt`;

letobjFile:File=newFile(strLocalFilePath);

letobjFileWriter:FileWriter=newFileWriter(objFile);

objFileWriter.open();
objFileWriter.write(strContent);
objFileWriter.close();

letobjSSHCommand:SSHCommand=newSSHCommand(strHostFQDN,strUsername,strPassword,intPort);

letintExitCode:number=objSSHCommand.putFile(strLocalFilePath,strRemoteFilePath);

objFile.deleteFile();

if (intExitCode!==0){
this.objLogger.info(`Error while copying content of${strLocalFileName} to remote location "${strRemoteFilePath}". Exit code:${intExitCode}.`);
}

returntrue;
}catch (objException){
returnfalse;
}
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like