Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [scripts]

A script is a series of instructions written in a "plain text" file. The script interpreter (for example, Bash or another shell, Python, Perl, Ruby, etc.) reads the file and carries out the instructions as if they had been entered at the command prompt.

2
votes
0answers
22 views

Creating bash if/then toggle

My intended goal is to create a script that when run, will check the state of a setting, then change it to the opposite state. The setting in question is regarding the manual or disabled state of ...
0
votes
0answers
12 views

Function doing sm if specific pixel's color is sm

I hope that you are doing well today. Firstly, sorry if I am not in the right place, I am kinda new to the scripting and programing - I am just amateur seeking for some answers :) I wanted to ask you ...
-1
votes
0answers
14 views

Why “can't fork” error, when trying to run “ps” command through script? [duplicate]

I'm running a script, where basically I'm trying to find the number of a specific process. My code is given below: #!/bin/bash name="someProcessName" process_number=`ps | grep $name | grep -v grep | ...
0
votes
1answer
17 views

ubuntu 14.04 OS not loading, /bin/sh problem

Lately I started learning SHELL SCRIPTING. I was practicing some commands. Unfortunately I did "mv test1.sh /bin/sh". In test1.sh which is my practicing script file which has "hello" text only. After ...
0
votes
0answers
18 views

rsync different user's files to external HDD via batch

How can I achieve the following scenario logged in as user a: ExtHDD is plugged in for user a. Once opened a shell via user b call the following script: unmount extHDD for user a mount extHDD for ...
0
votes
0answers
30 views

Detect image on screen and integrate it to a bash script?

I'd like to know if there's any package or command on ubuntu that can detect if a image or similar appears on screen and pipe its output to script. I would like to work on a video detection script, ...
0
votes
0answers
19 views

Can did I launch process separate of main process? In bash script

I try launch project on server and send query to him: similar to: #!/bin/bash java -jar patch/p-SNAPSHOR.jar curl -d localhost/go/param the script launches p-SNAPSHOT.jar and stops - waits for a ...
0
votes
1answer
16 views

How to emulate a remote host shell environment on my ubuntu 16.04 LTS workstation

On my desktop ubuntu host if I run a script with only the line echo $SHELL it prints /bin/bash But on a different host running busybox, if I do the same thing I get /bin/sh printed And I have ...
1
vote
0answers
9 views

Bash_alias, run a script with a parameter and close console [duplicate]

I just created a script that runs a command using a parameter like so: (firefox "localhost/?id=""$1" &) I created the alias like so: alias gotoid='/myscript.sh As you can see, my script ...
1
vote
0answers
13 views

Shell script Delimiter error

I have written below script to send mail of the o/p. #!/bin/sh input="/data/builds/i2SchedulerAutomation/Final.txt" tmpfile="/data/builds/i2SchedulerAutomation/Final.html" echo 'Content-Type: text/...
0
votes
0answers
14 views

OpenFoam Win 10, Ubuntu Bash installation fails

I am trying to install OpenFoam on ubuntu bash on Win 10. I am following these steps:OpenFoam installation on win 10 Ubuntu bash At this step: echo "source /opt/OpenFOAM/OpenFOAM-v1806/etc/bashrc" &...
0
votes
0answers
12 views

Using keyring to automatically authenticate with wget

My university offers all of the curriculum online and available for everyone that has a username and password. So naturally i wrote a shell script to just crawl in every needed course and download all ...
0
votes
0answers
21 views

SOLVED Switching user in automated scripts like cron jobs

If I run su -c "notify-send test" myusername as root, the command will be executed by myusername (me). But if I place a script in /etc/cron.daily or /lib/systemd/system-sleep and it is ...
0
votes
1answer
18 views

Where is to edit the firewall-rules for iptables and ip6tables correctly?

I want to set myself up the rules for firewall in iptables. But several queries have delivered different file-locations for iptables-rules. One location is in /usr/local/bin and there is to create ...
3
votes
1answer
37 views

Keep executed command in its tab (bash script)

I have a bash script that starts a terminal window with multiple tabs and executes a command in each of the tabs similar to this (and titles aren't supported, I know): #!/bin/bash title1="foo" ...
0
votes
0answers
30 views

Editing root crontab with startup script on fresh installed ubuntu server

I'm building a script for my ubuntu server. the script creates a lot of files which works just fine, but now i come to a part where i need to add a line to the crontab of the root user. If I do it ...
0
votes
0answers
32 views

unable to package .py and .sh files in binary format

My requirement is i need to package the below items authenticate.py script.sh trained.dat Once it is installed in the client place the source code should not be visible and the client can access ...
0
votes
1answer
265 views

Not able to execute script using sh <file_name>

I am Not able to execute script using sh file_name But it's working fine with command : ./filename Rgrds Aditya
1
vote
0answers
29 views

why are elements of script not run by cron?

Ubuntu 18.04.1 I have a series of scripts, written to back up files from locations on my PC to locations on my network storage. None of the commands appear to require sudo (I can run them all as a ...
1
vote
1answer
46 views

mv: target 'Nfilename' is not a directory error help

I'm new to Ubuntu and coding in general but have to use it to do some analysis of molecular sequencing data and I am stuck! I recently moved from my laptop to a more powerful PC (both with a VM ...
0
votes
0answers
34 views

Downloading a file from shell script which is part of PHP file [closed]

I have a PHP file where I have mentioned shell script file in shell_exec command. I have commands in script file which includes echo, netcat and wget I can see that all other commands are getting ...
0
votes
0answers
26 views

How can I send an email with hardware info when my PC boots?

I have a script called script.sh that creates a .txt file with hardware info. The script looks like this: #!/bin/bash echo "Sending Email With Attachment"; sudo lshw > /home/ondrej/hardware....
3
votes
2answers
151 views

Copy all files from certain file type extension in script

I am trying to execute the following command in a shell script where adir="mydir" and extType=*.txt cp "$adir/$extType" "$destination" However I get: cp: cannot stat ‘mydir/*.txt’: No such file or ...
0
votes
2answers
46 views

How to pass a pathname with a space in it to cd inside of a script

I am working on Windows 10 and am using the Ubuntu subsystem. Often I need to change between Windows directories and Linux ones, so I wanted to write a script that automatically converts a Windows ...
0
votes
0answers
27 views

Why temp txt files are created in ANSI?

I have a big log file and i need to cut a part of it and paste it in the end of the same file... so i created a script that looks for the chunks of code i need (sed) create a temp file ,paste it , ...
0
votes
0answers
30 views

Prompt for password after double click on .sh file in Ubuntu 18.04 [duplicate]

I have small file with some shell script that's required sudo privilages to be run - let's call it "foo.sh". Normally, I'd run it from terminal using: sudo ./foo.sh and it'd work just fine. But, I ...
0
votes
2answers
28 views

How to move the Script I created to another directory and run it from there by double click?

I made the script in my home folder, and it works perfectly, but I want to move it to another directory, for example to folder called "my scripts". How can I do it? I tried different ways with chmod +...
0
votes
0answers
13 views

Scripting Actions for attaching monitor in Xubuntu 18.04

Every time I attach my second monitor it defaults to mirroring the screen, and I use the "Displays" GUI to change the settings and position the new screen. I was wondering whether any of these actions ...
2
votes
1answer
39 views

How to split awk output to multiple lines for piping

I'm currently putting together a quick script that deploys multiple vagrant machines locally for dev purposes. Par of the procedure consists of adding the ssh key to the vagrant boxes. So far, ...
1
vote
0answers
59 views

Running shell script to launch mongod on startup but before login on Ubuntu 18.04 [duplicate]

I'm running Ubuntu 18.04 on VirtualBox. I am trying to run a shell script that launches multiple mongo instances. I want the script to run after the system reboots but before login I have added the ...
1
vote
0answers
69 views

Converting a string of Perl code to BASH code

I have this string of Perl code (which i didn't write) that it would be awesome if is converted to BASH code: perl -pe '$j=0; while ( s{.{$j}\K(\d+):}{/} ) {$j += $1+1}' By using it in terminal: ...
0
votes
1answer
51 views

Progress Bar Window / Bar in the notification area for a running shell script

I implemented some shell scripts to my dolphin context menue. Within the shells scripts i run some commands, which take some time. My question is: Is it possible to implement some code into the (a) ...
-1
votes
2answers
62 views

Testing expression in BASH fails [on hold]

----- UPDATE ------------ THIS QUESTION IS NOT RELATED TO UBUNTU AT ALL! ----- UPDATE ------------ I have a problem (on OSX for now) what I can't pass on. I am beginner in bash, I learn it recently....
1
vote
0answers
21 views

looping through Two menus and displaying outputs based on prompt

when the script starts it list a menu from files in a directory and prompt for selection, when a file is selected, another menu is displayed with what user wants to do,now the user wants to use option ...
0
votes
0answers
9 views

Ubuntu launcher `source` script before executing command

For a specific program I need to source a script file with a bunch of environment variables before launching it. I'd like to include that script file in the launcher icon of Ubuntu. Like, if I click ...
0
votes
0answers
18 views

Backup script for mysql [duplicate]

I would like to write a bash script containing next command: mysqldump -u root -p moodle > moodle_sql_backup_21_08_2018.sql I added #!/bin/bash but then I get stuck with two problems: -p ...
0
votes
0answers
48 views

I am stuck on writing a menu bash shell script [duplicate]

This script needs to have a menu with a list of options for the user to choose from. Each option when chosen will perform a command and output to the screen. At the bottom of the output there should ...
0
votes
2answers
47 views

How to read .sh_history from thousand of users?

The logic applies to many other objectives. And how to read .sh_history of each user from /home/ filesystem? What if there are thousand of them?
-1
votes
0answers
30 views

Why does loop with shebang bash not work while using bash directly works? [duplicate]

I have a script, test.sh, that is supposed to run a loop. The script looks like this: #!/bin/bash for i in {1..10} do echo $i done When run with ./test.sh the loop does not execute. But when ...
0
votes
0answers
10 views

up script in ovpn configuration file for Open VPN gives fatal error: could not execute external program

My openvpn finishes with the following: Sun Sep 30 01:35:11 2018 masquerade.sh tun0 1500 1552 192.168.255.6 192.168.255.5 init Sun Sep 30 01:35:11 2018 WARNING: Failed running command (--up/--down): ...
0
votes
0answers
11 views

Start script after file is placed in folder

Hi so my younger brother was in a bad car crash a while back and has lost all of his motor skills. With that I've been trying to automate encoding Anime and labeling, like he would do prior to the ...
3
votes
0answers
34 views

Gnome-screenshot doesn't always work from keyboard shortcut

I created a script to screenshot and save the screenshot directly, and I wanted to bind it to a keyboard shortcut. However, it only works about 50% of the time. If I run it from the terminal, it works ...
0
votes
1answer
39 views

How to use RCLONE with CRON

I have a script in a USER folder that works successfully when run manually. But I cannot get it to work when run via USER CRON (edited via crontab -e). There are web posts elsewhere by others who ...
0
votes
0answers
19 views

how to make python modules accessible by root

I am running an /etc/init.d script that which contains a line to run a python file like so python /home/my_user/some/file.py Since my /etc/init.d is being ran with sudo, I have noticed that certain ...
2
votes
1answer
46 views

permissions of shell script: how to write into /var

I am writing a backup script. The script is located in /usr/local/backup-scripts The files should be stored to /var/backup/subdirectory I want to run the script using cron job or systemd-timer. I ...
0
votes
1answer
22 views

How to append stderr to log_failure_msg in init.d script

To my understanding, in /lib/lsb/init.functions, log_failure_msg is the proper way to output a failure message to some log file. I was wondering if it were possible to do this. python some/script/...
6
votes
2answers
213 views

Trying to script deleting files from wildcards in a text file

I'm trying to script deleting files whose filenames match wildcards in a text file. I'm using the following if [ -z "$1" ]; then echo -e "Usage: $(basename $0) FILE\n" exit 1 fi if [ ! -e "...
1
vote
1answer
22 views

What is $previous is in this line of code in /etc/init.d/ssh

I will just be supplying the one line. Neither $previous nor $runlevel is defined before this. I can imagine what $runlevel is but how does $previous work here? run_by_init() { ( [ "$previous" ] &...
0
votes
0answers
17 views

How do init.d scripts specify --pidfile with start-stop-daemon command

I'm running ubuntu 18 and looking at the /etc/init.d/ssh file and I see that the command if start-stop-daemon --start --quiet --oknodo --pidfile /run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_opts; ...
0
votes
3answers
70 views

Run a Bash script to set up iptables at startup [duplicate]

I'm using Ubuntu 16.04 Server. I want to use a Bash script for iptables at startup, but I dont wanna use crontab or init.d. Is there any possible way to achieve this without them? #!/bin/bash IPT="/...