In shell scripting, a shell such as bash runs a file containing a list of commands (a script). The script is effectively a program and the shell is its interpreter.

learn more… | top users | synonyms

0
votes
1answer
54 views

Open up new terminal and run script with double click in Unity

I want to execute expect -c " spawn ssh user@10.0.0.0 expect \"assword:\" send \"pass\r\" interact " in a new terminal by doing double click in an .sh script. I tried ...
2
votes
1answer
53 views

ip netns monitor not working in a script

I'm trying to use ip netns monitor in a script to react to the creation of new network namespaces, eg: ip netns monitor | while read ACTION NETNS; do echo 'handling it!' done However I never see ...
2
votes
1answer
34 views

Run shell script on keyboard shortcut

I would like to run a shell script on the press of a button. The script works if I run it like usually: sh script.sh. But assigning a shortcut to it doesn't work. How would you do this in Xubuntu ...
0
votes
2answers
91 views

How to make the terminal prompt make sound every time i am prompted to write a command?

I want every time i have the command prompt (i.e, end of a command) to get a sound to get attention to the terminal [as i am using laptop \a character is not going to work with me]. The command i want ...
1
vote
1answer
45 views

Error: object “ip” is unknown , try “ip help”

I am trying to run trusted executables through a script. I copied the binary executable /bin/ip to a directory called Tools. I renamed the binary to eip. I have navigated to the directory tools and ...
0
votes
2answers
45 views

Can i make a commad execute in background without producing any output?

Is there a way or an option to make a command run in the background without the need to wait for it to end to get the prompt back? (just like mplayer command to play a music file in the background and ...
0
votes
1answer
32 views

Why output redirection is not working with the mplayer command?

The mplayer command is used to play a media file in terminal or a shell script and i gives some controls over it like move forward, backward in the file, etc. Sometimes i find it annoying so i want it ...
1
vote
1answer
62 views

How to make an export DISPLAY?

I'm execution a Java project on a distant server. My project generates a graphical interface. Here is the shell script that I'm executing on the server side : export ...
0
votes
1answer
29 views

watch internet connection thoguh shell

I just need to run a shell script when an internet connection is available. Is it possible to watch the internet connection arability through Shell scripting. ping google.com is the easy command to ...
0
votes
2answers
48 views

How to highlight second vowel from every word in a file?

I am trying to highlight every second vowel in a word to the colour red. What am I doing wrong? cat room.txt | sed 's:[AEIOU]:$(printf "${\e[1;30m}&${\e[0m}"):i2' Ps. Sorry for making it ...
3
votes
3answers
140 views

Can I call a .cpp program in Bash?

I am new in Bash programming. I want to call my C++ program in Bash file. My program is myProg.cpp: #include<iostream> using namespace std; int main() { cout<<"Salam! ...
3
votes
1answer
102 views

What are the differences between executing shell scripts using “source file.sh”, “./file.sh”, “sh file.sh”, “. ./file.sh”?

Have a look at the code: #!/bin/bash read -p "Eneter 1 for UID and 2 for LOGNAME" choice if [ $choice -eq 1 ] then read -p "Enter UID: " uid logname=`cat /etc/passwd | grep $uid | ...
1
vote
1answer
23 views

Bash script behaves fuzzily

I'm using this bash script to check if the content of two paths install and install1 passed as arguments is the same: #!/bin/sh du -a $1 | grep -Po "[0-9]+\t$1/\K.*" | sort -n > list.txt du -a $2 ...
1
vote
1answer
52 views

cutecom not comunicating

I need some help communicating with a serial port device. I have the serial port set to "auto" IRQ in the BIOS. The device (a Temperature controller) has the following Data protocol: Baud:9600 Tx ...
0
votes
1answer
62 views

How to accept root password through shell script [closed]

Is there any way that I can provide root password in the shell script without explicitly entering it through the terminal
1
vote
2answers
247 views

How to send a mail/write to other user through a shell script? How to send EOF?

if [ who | grep $user | grep pts ] then write $user message here EOF fi Here if I execute it, it is blocking at write and I have to enter a ...
3
votes
1answer
166 views

Open URL in default browser (Chromium) from terminal and give browser focus

I am trying to open an URL from the terminal window in my default browser which is Chromium: $ xdg-open 'https://www.google.no/?gws_rd=ssl#q=site:askubuntu.com+xdg-open' >/dev/null This will ...
1
vote
0answers
65 views

How to customize the font style in notify-send?

I am trying to change the format of text appearing in pop-up notification while using notify-send command. Here I saw that it can be done using HTML formatting. But that doesn't seem to be working for ...
1
vote
2answers
162 views

Is there any way to execute a shell script whenever I open a terminal?

I want to display a message showing "welcome to terminal" whenever I open a terminal. Any ideas?
1
vote
1answer
45 views

How can I print a variable to a file?

How can I print the contents of a variable into a text file? For example, I have the following script: #!/bin/bash #My Bash echo "saisir votre nom" read $name I would like to print the contents of ...
1
vote
1answer
44 views

How to move all subdirectories to current directory?

I'm new to shell script programming. Suppose we have a file hierarchy like this: /A/B/C/D /A/B/E/F/G /A/H/I /A/H/J/K Note that here we not only have /A/B/.., but also /A/H/.... All letters are ...
6
votes
1answer
162 views

Shell scripting bash: How to detect Alt+N keystroke?

I want to write a script that always listens in the background and execute a particular command when the user hits a specific key combination such as Alt + N. How this can be done?
0
votes
1answer
23 views

Website Files Permissions

I am trying to set all folders and subfolders (directories) to 755 and all files that are contained by folders and subfolders to 644. I don't know how can I do this from 1-2 commands. Is this even ...
4
votes
1answer
69 views

How to detect keystrokes?

I have a script running always at the background. Inside that script I have to write the codes to detect keystrokes, and once a particular keystroke is detected, the rest of the script must be ...
1
vote
1answer
42 views

Data transfer between two remote servers linux (sftp)

I work remotely trough my Linux system. I have data on server A which can be accessed only through SFTP. The second server is an HPC cluster. I want to fetch data in my HPC cluster working directory ...
1
vote
1answer
48 views

concatenate the argument of date into one string

my main program takes a time stamp having the format of the date as well as the time, separated by a comma, but it is still one string and one argument: #source main.sh '2015-02-10 00:00:00' Now, I ...
0
votes
4answers
325 views

bash script which checks input to see if it is “y”, “n” or other - not working

I have written this bash script which is meant to check your input to see if it is y, n or something else (this will be part of a larger project): #!/bin/bash echo "Have you updated the PATH ...
0
votes
1answer
31 views

confirm a default answer using read after a few seconds [closed]

I want to wait 3 seconds for the user to answer no. if so, then the process exits, if either user answers yes to the prompt or 3 seconds passes then y is given automatically to the question and the ...
0
votes
1answer
52 views

for loop over character array gives unexpected “(”

I am a bloody beginner in bash scripting and I am sorry if the following is very simple. The error I get is: 4: Syntax error: "(" unexpected I am basically trying to run the following in bash on a ...
9
votes
2answers
490 views

Case sensitivity in shell scripting

Consider this Bash script: #!/bin/bash echo Enter any character read char case $char in [a-z]) echo Lower case letter ;; [A-Z]) echo Upper case letter ;; [0-9]) ...
1
vote
1answer
152 views

Copying contents of subdirectories in their parent directories

I have a list of jpeg files in a directory like this (below is just a sample, like the structure is the same but this there are many fo0# sub-folders, not only fo01 and fo02, where each of these ...
3
votes
1answer
32 views

How can I set up ubuntu to switch back to English after a few minutes of inactivity?

I'm using Ubuntu for several years now and enjoy it immensly. I'm developing software in PHP and Javascript for a living. The only minor annoyance I have is that I would like the PC to switch back ...
2
votes
1answer
50 views

Shell scripting : Change in input stream not working as desired

I'm trying to create a shell script that can count words and lines in a file. (yes, I know you can do that using wc, but just for the sake of learning loops) Code echo "enter filename" read f if [ ...
0
votes
2answers
46 views

replace string in a file with another where both are saved in variables

I want to replace a string found in a file with another string, but both have a special character (in this example it is a . char) e.g 1.0 and 2.0 so this the is command currently used: sed -i ...
1
vote
2answers
32 views

Splitting a string not working

I'm trying to split a string but there is something wrong. If anyone could please advise. echo -e "\e[41m## i = $i ##\e[0m" str1=$i | cut -d'/' -f1 echo -e "\e[41m## str1 = $str1 ##\e[0m" and ...
1
vote
1answer
39 views

shell script not working properly

I'm writing the below script but it seems not to work as this is the output: ## entered first loop ## [==1.0]: command not found [==2.0]: command not found ## entered first loop ## [==1.0]: command ...
2
votes
1answer
29 views

Defining and incrementing a variable in bash

I've something like this: declare -r constant1=0 declare -r constant2=0 for xx in 1 2 3 4 5 6 7 8 9 10 do constant1=$((constant1 + 1)) for yy in 8 7 3 9 3 9 2 8 4 4 do ...
2
votes
1answer
20 views

Logarithmic shell expansion?

I know there is ** for exponentiation in bash. Is there a simple shell expansion for logarithms?
1
vote
2answers
140 views

how to see CPU and memory usage for a program after run it

I wrote a shell script and run it with terminal.script call another programs to run and have some child process. how can i see TOTAL memory and CPU used for that script after run it ? more generaly ...
1
vote
1answer
120 views

transmission-cli connected to peers but not downloading

I'm using my Ubuntu-Server and transmission-cli to download torrents overnight. When I try to download the Ubuntu 12.04.5 Server torrent transmission connects to various peers, but doesn't download ...
-1
votes
1answer
42 views

Command output to file, new lines at top [duplicate]

I'm rewriting some 20+ year old Unix scripts and I want the output to go to the screen and a file. I know this is possible with tee. Is there a similar command that stacks new lines on top, at the ...
0
votes
1answer
43 views

Run Matlab with a desktop launcher

I'm trying to make a desktop launcher for Matlab in order to run it from the desktop. This is how my desktop entry looks like: #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application ...
0
votes
3answers
40 views

Basic Shell programming question with && {

Hi just wondering about the use of && and { } in this example down below, does it mean that if you use the && and follow by { you write a shell script without having to create one ...
1
vote
0answers
13 views

pause process during lockscreen

I used WhatPulse back on windows and got it installed on Ubuntu, too, but now sometimes, when waking up from standby, it expects an internet connection immediately and builds up a lot of ram and ...
2
votes
2answers
80 views

Rotate images from terminal

I have a directory with a lots of image but they are in wrong orientation. I want to rotate the images to correct orientation (mostly ±90o). Using image (shotwell photo) viewer I can rotate ...
0
votes
1answer
70 views

How do i write a terminal script to setup ubuntu for me instead of spending days every time?

From what I understand I can make a text file with all commands same as I would type in terminal, make it executable and run it. Would running sudo mysetup.sh or mysetup.txt be OK so not typing PW ...
1
vote
2answers
92 views

convert with bash - trim/crop and center

i need a fast and reliable way to modify a lot of images. There is a lot of white around my pictures i want to get rid about. The problem is, it is a number of similar pictures, but they have ...
2
votes
1answer
73 views

Can there be two init processes?

I am new to Operating Systems (specifically Linux) and this is my first question here I want to ask, can there be two process with CMD = init (as given by ps - e command). I had two processes on my ...
0
votes
3answers
82 views

Shortcut to execute shell scipt? [duplicate]

I'm trying to create a shortcut that will run a .sh file deep in some directory without having to navigating to the absolute path. I have tried using aliases, which did not work as. Using soft/hard ...
0
votes
0answers
28 views

Reconnecting network through shell script

I've written following code to reconnect to network: #!/bin/bash while [ "$var" != "end" ] do pingtime= $(ping -w 1 192.168.1.107 | grep ttl) if [ "$pingtime" = "" ] then $(sudo ifconfig ...