node ssh2 shell unable to run apt-get install on remote machine

I'm doing a program in node.js to deploy my code from git to a server (Digital Ocean). I'm connecting to the server via ssh2 module and running commands via shell, like bellow:

var Client = require('ssh2').Client; var conn = new Client(); conn.on('ready', function() { console.log('Client :: ready');, stream) { if (err) throw err; stream.on('close', function() { console.log('Stream :: close'); conn.end(); }).on('data', function(data) { console.log('STDOUT: ' + data); }).stderr.on('data', function(data) { console.log('STDERR: ' + data); }); stream.end('sudo apt-get update -y\nsudo apt-get install -y build-essential\nexit\n'); }); }).connect({ host: 'x.x.x.x', port: 22, username: 'yyy', privateKey: 'zzz' });

The command "apt-get update" works fine, but the command "apt-get install build-essential" (I have tried to install other programs, like vim and curl) seems to freeze the stream on output's last line. I think it can be caused by the prompt "Y/n" of the apt-get, but I couldn't find a workaround for it. Someone know how to deal with it?

-------------Problems Reply------------

Try to change \nwith &&:

stream.end('sudo apt-get update -y && sudo apt-get install -y build-essential && exit');

Category:node.js Views:3 Time:2019-01-11
Tags: node.js

Related post

  • Why is apt-get install libsqlite3-dev giving me a 404 error? 2012-04-26

    I'm trying to install a sqlite3 gem using bundler and am getting the common Failed to build native gem extensions error. I'm trying to install the necessary files to fix this and successfully installed ruby-dev using apt-get install, but when I run a

  • Running apt-get for another partition/directory? 2010-10-17

    I have booted my system from a live Ubuntu CD, and I need to fix some package problems. I have mounted my hard drive, and now I want to run apt-get as if I booted normally. ie change the working directory for apt-get so it will work on my hard drive.

  • Running apt-get on EC2 without coughing up for a bunch of bandwidth charges 2009-05-19

    I'm running Ubuntu on EC2 (using the alestic community AMI) and on startup my new instances use up a bunch of bandwidth running apt-get upgrade etc. Bandwidth between EC2 instances is free... anyone know if there's a mirror of the Ubuntu packages som

  • How can I get chef to run apt-get update before running other recipes 2012-02-12

    Right now I have the following in my Vagrantfile: config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "cookbooks" chef.add_recipe "apt" chef.add_recipe "build-essential" chef.add_recipe "chef-redis::source" chef.add_recipe "openssl" chef.a

  • the problem of using sudo apt-get install build-essentials 2011-06-26

    I was trying to use sudo apt-get install build-essentials to install g++ compiler on my ubuntu linux box. But it gave me the following message Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locat

  • Parsing output of apt-get install for progress bar 2009-11-07

    I'm working on a simple GUI Python script to do some simple tasks on a system. Some of that work involves apt-get install to install some packages. While this is going on, I want to display a progress bar that should update with the progress of the d

  • R: apt-get install r-cran-foo vs. install.packages("foo") 2010-01-31

    When installing R packages (say mcmcpack in this example) under Ubuntu I have the choice between the following two methods of installation: # Let the distribution's packaging system take care of installation/upgrades apt-get install r-cran-mcmcpack #

  • apt-get install pgadmin fail with libgtk2.0-0 & libwxgtk2.8.0 not configured yet 2011-07-20

    -Edit after closing- I try to install ruby 3 to a Server and that kind of work, but when I check out my project and try bundle install I get the error message, that gem pg needs pgadmin, that is why I asked directly for the command. In this case it i

  • apt-get install python-software-properties dependency problems 2011-08-31

    So, I was trying to add a repository using add-apt-repository and I got this error: sudo add-apt-repository ppa:gijzelaar/opencv2 [sudo] password for foo: Traceback (most recent call last): File "/usr/bin/add-apt-repository", line 8, in <module

  • Using "apt-get install xxx" inside Python script 2011-12-12

    currently I need to install some package using apt or rpm, according the OS. I saw the lib "apt" to update or upgrade the system, but it is possible use it to install a single package? I was trying to use too "subprocess": subprocess.Popen('apt-get i

  • linux ubuntu server, can't complete "sudo apt-get install ubuntu-desktop" 2012-01-29

    I'va installed ubuntu server 10.41 in Vm ware, and I would like to install the desktop but each time i try to do the command sudo apt-get install ubuntu-desktop this error shows up: Failed to fetch

  • Recompiling nginx after using apt-get install nginx 2012-03-02

    I originally installed nginx via apt-get install. It works just fine. Now, I want to install some 3rd party modules and I have to recompile nginx. So I tried to recompile. It went through the motions and then I realized that my original version was s

  • Advanced Virus. Unable to run exe files, install programs, run command prompt, or open registry. please help! 2015-01-14

    Ok so as the title says I am unable to run any files, install anything, open registry, or run command prompt. When i try to install something it says that it is blocked on this computer. When i try to run something in command prompt it says i dont ha

  • What does 4: mean in g++ apt-get install version string? 2009-05-27

    On EasyPeasy 1.1 (for mini notebooks) derived from Ubuntu I installed g++ using apt-get: $ apt-get install g++ One of the lines displayed was: Setting up g++ (4:4.3.1-1ubuntu2) ... What the does "4:" mean? $ g++ --version g++ (Ubuntu 4.3.2-1ubuntu12)

  • Can `apt-get install` be used for JDK? 2009-08-04

    I've been using a linux machine for less than two weeks, so I am extremely new to Linux. I'd also like to install the Java Developers Kit. How should this be done? Is there an apt-get command, or should I just click on the download button at Sun's we

  • There is no apt-get install ruby1.9.2 yet on Linux? 2010-09-09

    The page only says 1.9.1 for Linux. Right now I am using RVM to do an rvm install 1.9.2 and it needs compilation. There is no apt-get install way to install it? Is there a way to list all Ruby version apt-get ca

  • Jenkins User on Apt-Get Install Installation 2011-06-04

    I just installed Jenkins on my Ubuntu server via the debian installation steps (using apt-get install). I want my build to pull from a private git repository on GitHub. With that, I need to use SSH access to get to my repository. Most of my search re

  • How can I change the apt-get install directory 2011-12-19

    The default install directory of apt-get is /opt. Can I change it to another directory? --------------Solutions------------- Best way I can think of is to use a symbolic link note that not all programmes are installed to the same directory and /opt m

  • Unable to run MSE after installing.I was using it for 2 years and then i tried deinstalling and reinstalling but failed to run the programme,plz help 2012-08-26

    Unable to run MSE after installing.I was using it for 2 years and then i tried deinstalling and reinstalling but failed to run the programme,plz help --------------Solutions------------- Were you having problems with the program? Why did you need to

  • Will this bash loop apt-get install all my anaconda packages? 2016-12-02

    I don't want to just try it and mess something up. $ dlpackages=$(ls -l anaconda3/bin | awk '{print $9}') $ for package in $dlpackages; do sudo apt-get install $package; done or as root: $ for package in $dlpackages; do apt-get install $package; done

  • How can I run an application on a remote machine by ssh? 2011-06-29

    How can I run an application on a remote machine via ssh? I tried using JSCH, this way: Properties props = new Properties(); props.put("StrictHostKeyChecking", "no"); String host = ""; String user = "myuser"; String pwd = "mypass"; // i

  • Unable to connect to wmi service on remote machine 2013-05-21

    I am using VAMT 2.0 to activate Office 2010. Now, while activating the computers, I am getting the error message as "Unable to connect to wmi service on remote machine". VAMT is able to find some computers. I've tried disabling the firewall restartin

  • Running a program on a remote machine as part of continuous integration 2009-10-22

    We use TeamCity, nant and psexec to run a command on a remote machine as part of the release packaging. Everything works fine when I run the nant from the console but when running from teamcity psexec hangs (freezes) 50% of the times. I looked throug

  • how to get file from remote machine 2010-12-09

    i have got a remote machine which i can access using ftp (it has static ip with userid and pass). i am able to send file to that location using FTP through but don't know how to get that file back using through code. actually wants 2

  • Run a script on my remote machine from my machine even when the connection is lost 2012-01-09

    I have a remote machine where i need to run some script say ./ I am using ssh to login to the remote machine and run the script but when the network connection is lost the script doesn't run. How can i run a script on my remote machine from my

Copyright (C), All Rights Reserved.

processed in 0.135 (s). 11 q(s)