bashaptgitpod

How can I insert a word inside a command in Linux?


Now, I have a simple file that runs every time I open my Gitpod(cloud env). I am making a file so that I can access it via ngrok. But, I need some packages, like wget, unzip and neofetch(for my ease). But it opens in a different terminal and I have to enter y every time. Is there a way to put y in the command and it will install automatically?

Source code for the file:

#!/bin/bash

sudo apt update

sudo apt install wget unzip openssh-server neofetch -y

sudo service ssh start

echo "Set Password for Gitpod as gitpod"

sudo passwd gitpod

wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"

unzip "ngrok-stable-linux-amd64.zip"

echo "I need your ngrok auth token. Enter it below."

read -p "ngrok authtoken:" authtoken

./ngrok authtoken $authtoken

echo "Authtoken activated, now activating server..."

./ngrok tcp 22

sudo apt install wget unzip openssh-server neofetch -y

Have I put correctly in this line? If this works, whenever I get a cloud environment, it could just install all deps and go ahead.

Output: NOT an answer, an output.

The fish shell I like and use's output:

Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
gitpod@ws-588be66f-373e-46f0-8342-5d39b8c863f4 /w/coder-lg-blog-codedoc (master)> sh .gitpod/ngrok.sh
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease                                           
Hit:3 http://archive.ubuntu.com/ubuntu focal InRelease                                                     
Hit:4 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease                                         
Hit:5 https://deb.nodesource.com/node_16.x focal InRelease                                                 
Hit:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease                                             
Hit:7 https://apt.llvm.org/focal llvm-toolchain-focal InRelease      
Hit:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease     
Reading package lists... Done
Building dependency tree       
Reading state information... Done
107 packages can be upgraded. Run 'apt list --upgradable' to see them.
.gitpod/ngrok.sh: 5: y: not found

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Yeah its a cloud Gitpod env for my blog and I want SSH tunneled via ngrok but it says this:

/repo > .gitpod/ngrok.sh: 5: y: not found

How can I fix this? The mod deleted the last output so please don't delete this! It is mainly an output of the Gitpod Terminal.


Solution

  • Please don't delete.

    By @Biffen and this is the solution!

    That error doesn’t look like the result of the code in the question. Are you running the strange suggestion in one of the answers; | y? That won’t work. Have a look at this.

    Thanks to everyone who helped here, and I am marking this as answer, because Biffen's reply was a comment.

    Edit: In 2 days as of now, I can mark this as answer, because, Stack Overflow said so.