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.

0
votes
0answers
10 views

Socat executing commands with arguments

I have a socat running on my ubuntu and I need it to execute a bash script with the input from the tcp stream as arguments for the script. For example, if the client sends "-l -w" then the socat ...
0
votes
0answers
12 views

'systemctl suspend' seems to hang and doesn't execute script in system-sleep

I have some trouble with suspending ubuntu 18.10. 'systemctl suspend' seems to hang waiting for the network and not reaches a state where executables in '/lib/systemd/system-sleep' are called. I try ...
0
votes
1answer
31 views

Run a script on boot

I have a script to start a java application automatically. # colors red='\e[0;31m' green='\e[0;32m' yellow='\e[0;33m' reset='\e[0m' echoRed() { echo -e "${red}$1${reset}"; } echoGreen() { echo -e "$...
3
votes
0answers
33 views

Get ok message when installing deb with apt in terminal (from context menu or click)

I find apt in terminal as the best way to install a program from a deb package. As I prefer it to other gui tools, I want that in the context menu for deb files or as a launcher among applications in ...
0
votes
0answers
21 views

How to do one to one mapping in shell script? [duplicate]

Dear Ubuntu Help desk, I am having two arrays namely X and Y of size 1:10, I need to read each values from two arrays [X(1),Y(1)] and [X(2),Y(2)] likewise. Kindly help me out how to write a shell ...
0
votes
0answers
25 views

Scripting with multiple tasks

Clarification this is Homework I don't just want an answer but to know how to in the future as well. Write a script (called phone_num.sh) that does these tasks: Read the phone numbers in the data ...
1
vote
2answers
39 views

How can I move content of a txt file to another using Bash Script?

I want to copy the whole content of the file into another multiple files as group wise. Suppose If I select 10 .txt files then the contents of those files should be copy and paste in a another one new ...
0
votes
0answers
19 views

How to put special characters with lynx script?

I'm writing a script to send any code to a page by making the lynx to type it completely but I don't know how to make it print some special characters: '*' , key * doesn't work '\t', key <tab> ...
0
votes
0answers
22 views

Wallpaper rotation with python and cron

I've written a small piece of python which generates a list of eligible wallpapers from my art collection and then sets a random one to my desktop background. The code works, and if I run it manually ...
-2
votes
0answers
29 views

Awk has a command line option I see [on hold]

Used in lots of examples "--cpp", I cannot find a reference to this option in any of the man pages, is there a reference for it or documentation?
0
votes
0answers
11 views

Calling a Pyramid view from a Python script [closed]

I'm working on system built in Pyramid and one of the views is for importing data. I'd like to make a script that will call that view. I'm assuming this is possible in Pyramid but I haven't found any ...
0
votes
0answers
24 views

How do I assign a variable in tcsh whose name is expanded ($) from another variable?

I have a part of script as below set n = 0 while ( "$n" <=10 ) @n = $n + 1 set name_$n = (`sed -n "$n"p name.txt`) end I want to add this line under cycle: set inst_$n = (`cat name2.txt |...
1
vote
1answer
51 views

Assigned variable for pipeline is not working

I have a shell script to check port status. After checking the port if it is busy then will kill it. #check port and kill checkPort(){ check=$(sudo netstat -nlpt | grep 2020 | awk '{print $6}') ...
0
votes
1answer
24 views

Changing text on a file using scripts [duplicate]

I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.
-1
votes
0answers
15 views

Script to delete users not on a text file [duplicate]

I have a list of users I want to keep on my computer, but I want to delete all the other users with a script. Can anyone help? I'm new to scripting. Make it so only users greater than 10000 get ...
-1
votes
0answers
23 views

I cant get cron to work [duplicate]

sudo crontab -e >> { *1 * * * * date +'%d/%m/%Y %H:%M' >> ultimoscript.txt } My goal is to make a script scriptexample that crontab program me. I want you to write in ultimoscript.txt the ...
1
vote
1answer
66 views

How to write a shell script to check port and kill it?

I have a command to check the port and kill specific pid running on that port. But I want to modify it to, Check port is busy or available If the port is busy then kill the pid How can I do this? ...
0
votes
1answer
32 views

Ubuntu using Linux Subsystem for Windows .sh problem

I'm trying to run a .sh script in my home directory and I get the following error. -bash: ./test.sh: /bin/env: bad interpreter: Permission denied When I try to sudo the script I get a similar error ...
0
votes
1answer
25 views

how to migrate the hidden files using rsync

I am using the command below, in my target sever: rsync --ab myuser@sourcehost:/source_dir/* target_dir But this is not able to sync the hidden files present source_dir anything I need to use any --...
0
votes
2answers
50 views

How to separate output of variables [closed]

I want to write a script to separate outputs. Output should be like this: 192.168.94.139 middle of loop 192.168.94.140 middle of loop After separating to the new line I want to run some ...
0
votes
0answers
15 views

Bash script to automaticly change a given user's password [duplicate]

So, I know that the passwd command allows me to change my own password, and if run with sudo, allows me to change anyone's password, but what if I want a script to do it? I have a script that grabs a ...
0
votes
0answers
51 views

First bash script: computer to dropbox backup help

I have the following script in /.backup with a symlink to cron.weekly. The goal is to have my entire system encrypted, compressed, and saved to dropbox every week. This is my first bash script and I'm ...
0
votes
0answers
33 views

Crontab to run a webpage containing php script every 15 minutes not working [closed]

I have a php script on a webpage that inserts data into database. I want it to run periodically every 15 minutes. The address to my webpage is /var/www/html/root_folder# webpage.php Is this right ...
0
votes
1answer
46 views

Setting environment variable for different tabs using gnome-terminal

In order to set up a number of applications, I'm trying to do something similar as: gnome-terminal \ --tab "app1" --working-directory=dir1 -e "export app=1 & npm start" \ --tab "app2" --working-...
0
votes
0answers
19 views

Can we run shell scripts which are located in gitlab from Jenkins

I have a Jenkins parameter job to deploy artifacts to the remote server. I wrote a shell script to check whether there is a directoy called backup in /var/www/test.com path if not create a directory. ...
1
vote
2answers
46 views

Create a file to automatically check user list for users specified

I am realitively new to bash scripting, but have created this from my intense googling I am attempting to create a bash script to run on Ubuntu that will check the user list and find any users that ...
1
vote
1answer
33 views

how to set umask permissions mask to 777?

I'm interested in creating a shell script that is capable of creating various operations (creating files,users, groups and more), and for that it's necessary to change the permissions mask.
2
votes
1answer
36 views

how to create a regex string where you don't know what to escape

I have a passwd file with the line containing root being: root:6UZSjeWUui3JQ:0:0:root:/root:/bin/sh I want this line to be changed to: root:$1$dog$cNv/OuAd7CMNdrhWsHXAR.:0:0:root:/root:/bin/sh ...
1
vote
1answer
61 views

trying to write bash script that sends email with output from two variables ubuntu 18.04

The problem I am having is that the action I am looking for is for sendemail to send myself an email that contains both w output from the ssh user and output from doing an lsof -u on $SSH_USER to see ...
1
vote
1answer
35 views

argument not recognized for-loop

I'm new pretty new when it comes to creating scripts in linux (I also don't really know on which terms to use like bash/shell), but I have the following command in a script which I want to execute ...
0
votes
1answer
20 views

cron processing only half of script

script: curl -s http://api.ipify.org > ~/ip.txt && [[ -s ~/ip.txt ]] && ip=$(cat ip.txt) && echo $ip > ~/newIP.txt || echo WAN IP is blank: curl, latency or internet ...
2
votes
1answer
100 views

read input from a file and append that values to variables using shell

I'm trying to write a bash script to read a file as input and append the values/data in that file into variables and the values of the variables should be updated each iteration based on the input ...
1
vote
1answer
47 views

Command not found after setting source in bash script [duplicate]

Following the instructions here, and everything works fine manually. However, when I use the instructions in a bash script, I get rbenv command not found because the source ~/.bashrc didn't execute ...
2
votes
1answer
41 views

Save all command and all output (using script across terminals)

For a short period of time, I want to save the command history and output of every command I run in any terminal I open. It should all go in the same file. So basically I want to run a command (or ...
2
votes
2answers
110 views

Script for merging files in multiple nested directories by symbolic link

Basically I am looking for a script to automate stuff (See picture below) in Ubuntu. I'm thinking of using a bash script but other solutions (eg. python?) would also be excellent. 1) Suppose I have a ...
0
votes
1answer
28 views

Script for creating users on new servers

So I am in this situation where we have started adding a bunch of new servers because we are getting new clients, therefore, we need new servers for each new client we get, and with that follows the ...
0
votes
2answers
47 views

How to write a script that automates an user setup in Linux using Ubuntu? [closed]

Hello I'm asking for assistance creating a script that automates an user setup in Linux Server using Ubuntu? Also, how to create a script that backups shared files every 12 hours?
0
votes
1answer
22 views

Running python script from shell script with newline

I have a python code that I want to run from the shell script. This one works python train.py --dataset './datasets/lausanne' --timestep 30 --obs_len 8 --loader_num_workers 1 --num_epochs 100 --...
0
votes
0answers
6 views

I need help to log process details for every 5 minutes for each disk or media vise. can some one help?

Basically I need to have a logging enabled for disk wise information of processes which are utilizing that perticular disk at given point in time. and I want that log at single place. can some one ...
0
votes
0answers
19 views

Reading system varibles in script

I am trying to read a system variable that is XDG_CURRENT_DESKTOP from a shell script. echo the variable in terminal works fine. but when running it within a bash script it echoes empty due to that ...
1
vote
3answers
82 views

How to write a script that backs up printed documents every 6 hours?

I am currently working on a project where I have to build a Linux network on a virtual machine using Ubuntu 18.04. I am currently trying to figure out how to write a script that backs up the printed ...
0
votes
0answers
28 views

How can I auto-close an urxvt terminal after executing an expect script?

I've written a script to handle quick copying of passwords to the clipboard: #!/usr/bin/expect -f spawn -noecho zsh expect "$ " send "pass show -c " interact exit This script is launched like this: ...
0
votes
1answer
51 views

Spaces missing from strings in an Bash array

I found a strange thing and will be nice if somebody can help to fix it. #!/bin/bash # dockerdir="docker" step_1=("nginx" "create" "default.conf") step_2=("nginx" "use" "default.conf" "replace" "...
1
vote
1answer
27 views

Execute sudo Bash script as another user while being root

I am logged in as root and want to execute a Bash script with sudo permissions as another user. This is the test Bash script in /home/me/sudo.bash: mkdir -p /etc/test # Creating an /etc directory to ...
0
votes
2answers
43 views

Revisiting Bash vs Source difference

I want to ask a question about bash and source. I acknowledge they are both used with .sh extension files such as bash setup.sh source setup.sh However, I wanted to know a difference between those ...
0
votes
0answers
40 views

.sh script not working with crontab but does run standalone fine. Ubuntu 18.04

I'm having trouble getting this script to work with crontab. The script works standalone when ran. I'm running Ubuntu 18.04. Here is the script. It's a simple backup script which uploads a compressed ...
0
votes
0answers
33 views

Where should user scripts go? [duplicate]

Writing my first project, which is a small NordVPN switching utility - a system tray icon. It’s written in Python and does not require any special privileges. I intend this to be used by one user only....
0
votes
0answers
9 views

How to pass command name as arg list and iteratively call them [duplicate]

I am a beginner at bash scripting and trying to write a program that takes a list of command name as the argument and execute all the commands. My script is for cmd in $@[*] ; do echo "-----------...
0
votes
0answers
24 views

call python function inside shell in pycharm

I am using python 2.7 and Pycharm 2017.3.3, and I have installed the shell plugin for Pycharm. There is a shell script that when I run it in terminal it works properly, but when I want to run it ...
-1
votes
0answers
38 views

How to reload .bashrc for the shell calling a script

How do I force the shell i called a script from to reload .bashrc? I'm trying to make a "new box" script that sets everything up the way i like it. Everything works, except for reloading .bashrc. I ...