A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

3
votes
1answer
22 views

Auto disconnect from WLAN if unused

For Nokia N900 there is an app called AutoDisconnect which monitors the WLAN usage and closes the connection if the traffic is very low. I'd like to have something like this on my future notebook in ...
16
votes
5answers
831 views

How can I propagate my SSH pub key to a list of servers without having to type my password in over and over?

I was recently given username/password access to a list of servers and want to propagate my SSH public key to these servers, so that I can login more easily. So that it's clear: There is not any ...
0
votes
0answers
17 views

Script requesting information upon boot

The idea is to create a script that runs as root upon boot (either before a potential X or GDM starts or after). The challenge is that this script needs input from "the one at the keyboard" - without ...
0
votes
2answers
59 views

export PATH permanently [duplicate]

I have exported the PATH but once I switch to a different terminal or reboot Debian, $PATH is reset. Here are the steps I take: ~$ vim scripts.sh #!/bin/bash echo "Hello" I save it as mybash.sh ...
-2
votes
0answers
29 views

Find HTML tag and add it to text editor with script [closed]

Is there a way to open a website find a specific HTML tag and get inner text (or inner HTML) and paste it to text editor or text file. I'm new to Linux.
1
vote
1answer
35 views

Shell read script for sftp

I have this working: % cat read.sh !/bin/sh file=list.txt while read line do echo "$line" cut -d' ' -f27 | sed -n '$p' > file2 done < "$file" % cat list.txt sftp> #!/bin/sh sftp> ...
0
votes
2answers
62 views

Cron job which runs every 5 seconds

I need to create an cron job with the following functionality: The job should go to a particular directory and touch one file every 5 seconds. It should run for only 1 minute. The logic is to ...
1
vote
0answers
56 views

How to set Ruby GEM_HOME and GEM_PATH

I'm a NOVICE user of Linux and using Linux mint 17.1 I've reinstalled Linux mint 20 time in last 3 days for that issue but could not fix it I'm trying to install ruby on rails using rvm what ...
0
votes
1answer
33 views

Take output field data string into variable

I want to grep for some specific lines from a log file, and then capture a specific part of that output in a variable and use it in other commands. The grep command I have is the following, where $1 ...
1
vote
0answers
34 views

What's in your script Swiss Army knife? [closed]

I've been using Linux pretty heavily that past few months and I want to up my game. But so far my scripts have been focused on speeding up my development time. I'm looking for scripts that will just ...
1
vote
3answers
50 views

Remove special pattern ^M from script which got appended after FTP from windows to Unix

I send a windows file using FTP to an unix system and got appended ^M wherever a new line was intended, and I just want to remove them. One method which I can opt is to run dos2unix command. Can ...
1
vote
3answers
213 views

How can I run a program as a root user when my Ubuntu 15.04 machine starts up?

On Ubuntu 15.04 I have this file: /usr/local/bin/myscript (it's a script I made). If I run this command under my account, it will do what I need it to do as a root user: sudo /usr/local/bin/myscript ...
-7
votes
0answers
38 views

UNIX script to display the filename [duplicate]

How to answer the below interview question: With a path and filename of "/mydir1/mydir2/mydir3/myfilenane.dat" write a UNIX script to display the filename
1
vote
2answers
55 views

Pipe to my own script

I've recently noticed this message from grep "grep: warning: GREP_OPTIONS is deprecated; please use an alias or script" I receive this warning because --color=always is defined in my .bashrc file. ...
3
votes
1answer
38 views

Solaris: PKG - Script To Verify All Packages Except for a Few

I'm trying to verify the all packages except for a pre-defined list of packages that I know are going to fail for known reasons. This script is going to be run on all Solaris systems within our ...
4
votes
2answers
87 views

Checking if a command is a built-in in ksh

How can I check if a command is a built-in command for ksh? In tcsh you can use where; in zsh and bash you can use type -a; and in some modern versions of ksh you can use whence -av. What I want to ...
2
votes
1answer
31 views

Scripteable GPT partitions using parted

I am partitioning eMMC using following commands in the script, parted /dev/mmcblk0 --script mklabel gpt parted /dev/mmcblk0 --script mkpart primary ext4 32MB 132MB parted /dev/mmcblk0 --script mkpart ...
0
votes
1answer
71 views

Shell Script Help - Automatically assign users to group

Recently, I have just started to learn linux and I am currently trying to make a shell script that can automate the task of creating user accounts, assigning them passwords and then assigning them to ...
-1
votes
2answers
32 views

Extracting certain data within a script output file

We have a script that runs several commands and rolls up all the output and inserts in into a log file. One of the commands it runs is "netstat -anp". I'd like to be able to search this file for all ...
1
vote
3answers
63 views

Difference between sh -x and ./ for script execution

So I have a simple shell script. What is the difference between the two commands in execution? Is there a preferred way? $sh -x foobar.sh OR $ ./foobar.sh I found the script executed slower when ...
0
votes
3answers
72 views

Remove lines in a shell script

I have this file: # more file.txt 2c2 lns-ld-wall-01-t2 old:261,260 4c4 Prive_ORANGE old:258,259 I need to remove all lines like this one 2c2 and this one 4c4. How can I do in a shell script?
0
votes
1answer
24 views

Filtering Log Output on Separate Lines

I did a recursive grep in a directory to find all files that would match as follows grep -ER "match_string1|match_string2" /path/to/dir/ What I get as output is: ...
2
votes
1answer
35 views

Shell Scripting: Deleting or moving files from one directory that match filenames from another directory

I have a very specific and odd problem to solve. I'm working as a research assistant and I've been producing a ton of figures. In one directory, I dump .pngs to view casually (limited space here) and ...
-2
votes
2answers
69 views

Parsing a flat file using shell script

I have a file like in following format User:blala Pass:blala IP:***.***.**.** I tried with IFS but it is not working input="/path/to/your/input/file.cvs" while IFS=',' read -r f1 f2 f3 f4 f5 f6 ...
-1
votes
0answers
7 views

rpm package not updating as I update the spec file

I have some statement the %post section of my rpm spec file of the form echo "printing A" I updated the spec file to make it "printing B" but the new rpms I'm creating still echo "printng A" What ...
0
votes
1answer
24 views

How to execute several lines into a .txt

I am using SSH; In a folder I have the next files: -rwxrwxr-x 1 german german 48 Apr 29 10:45 prueba.txt -rwxrwxr-x 1 german german 23 Apr 29 10:43 script1.sh -rwxrwxr-x 1 german german 23 Apr ...
0
votes
1answer
41 views

Script for update

I need your help in a script used for update : OLD="int 10" NEW="int 20" i=0 DPATH="/home" for f in $DPATH do sed -i "s/$OLD/$NEW/g" $f let i++ echo "modified:" $f done what i need ...
2
votes
2answers
44 views

Does zsh expansion work differently in non-interactive scripts?

I'm currently working on a pretty simple zsh script. What I often do is something like: mv */*.{a,b} . When I run that within a zsh script, it seems to expand differently and fail while it works in ...
0
votes
2answers
30 views

Add some text while output to file

Assume I have this command: ./clang-$j.out >> clang-result.txt and the each output for clang-$j.out is a fixed-length hash value (each program per line), however, I want to distinguish them by ...
3
votes
2answers
50 views

Detect and respond to ping in userspace

Is there a way to make a linux system react or do something when pinged from another device, besides just sending a reply (or not)?
9
votes
2answers
414 views

Jump out of a process when it get stuck

I have written a loop to iterate all .out c binary file and copy their outputs into a text file (the output for every binary file is just a one line hash value, one line output for one program). Here ...
2
votes
1answer
27 views

How do I detect which device was recently created by pppd?

I'm trying to setup a VPN over SSH using PPPD (following the Arch Wiki). The command given is: /usr/sbin/pppd updetach noauth silent nodeflate pty \ "/usr/bin/ssh root@remote-gw /usr/sbin/pppd ...
2
votes
1answer
55 views

How do you make a toggle key using Autokey?

I want to use Autokey to toggle the e key on and off in a program called "xyz". So if I press e, the program thinks I'm holding down e. I press e again, it thinks I released it. How do you do this ...
1
vote
1answer
49 views

Extracting duplicity backup data

I've made some backups of my previous systems using Deja Dup (duplicity). In my current distribution it's not available, so I've simply extracted the data. Now in order to make that data meaningful ...
0
votes
1answer
80 views

Run script on multiple hosts [duplicate]

I have below script which creates user list and also filters ignore.txt file to ignore matching usernames. I would like to run this script on multiple hosts like hostA, hostB, hostC. Like if I run on ...
1
vote
0answers
22 views

Need help with a network manager command line script

I am looking for some help in creating a script. As RHEL boots up and I login, I'd want to manually run a script which would: Identify the active ethernet interface (the eth ID being used). Ask ...
-3
votes
3answers
74 views

Delete line from files

I have 8 files in a folder. If any of these files has 2 lines I need to remove the second line from that file. If a file has more than 2 lines then then I do not need to do anything to it. Can anyone ...
1
vote
1answer
39 views

delete redis keys that have been inactive for 30 days

I've installed a web app called scrumblr which uses redis as a database. What I am attempting to do is delete all keys that have been inactive for 30 days, or have not been accessed in 30 days. I ...
2
votes
2answers
75 views

Change Password Programmatically

In the current version of Raspian, I know it is possible to change the password of the current logged in user from the command line like so: sudo passwd which will then prompt the user to enter a ...
1
vote
0answers
20 views

How to disable AC power supply from CLI

This article among others suggested the following to prolong battery life: Keep cool. Operate in mid SoC of 20–80%. Prevent ultra-fast charging and high loads (most Li-ion) The main issue here ...
1
vote
1answer
29 views

How to change configuration of detox (dash instead underscore)?

I found, best to this moment, a solution when changing all those annoying filenames in large quantities, making them readable and easier to manipulate with in command-line. So I found, among many ...
0
votes
1answer
34 views

Filter grep output

Using grep "val" index.php I get the list <td class=val> 7.6</td> <td class=val> 58</td> <td class=val>1013.8 </td> <td class=val> 1020 </td> <td ...
0
votes
1answer
19 views

Connecting to Windows server from unix through script

I am trying to connect to a Windows server say 10.1.1.10. This servers has a folder named RAJ in which there are multiple .zip files. All these zip files contain a text file called XYZ.txt. Now i have ...
0
votes
1answer
69 views

How to parse an awk variable

I'm trying to pull some information out of a log file, looking back over a specific period of time (e.g. the past hour). I've found the following awk construct that works, capturing the data as a ...
0
votes
2answers
36 views

Change only the year on the output of the “date”-command

date for example displays Fri Apr 17 20:16:01 IST 2015 Now I want to change only the year so date should display Fri Apr 17 20:16:01 IST 2016 in this example. How to add 1 year to the output of date ...
2
votes
3answers
74 views

Command line options with argument in shell script

I have a script to get ldap user name, email and mobile number: #!/bin/bash echo -n "Enter Unix id > " read UNIXID ldapsearch -x "(cn=$UNIXID)" | awk '/givenName/||/mobile/||/mail/' Here is the ...
4
votes
2answers
198 views

Best and short way to run a program if another is not installed

I have this code: #!/bin/bash num=${1:-undefined} cmd=$(which {banner,echo} | head -n1) until [[ "$num" =~ ^[0-9]+$ ]]; do read -p "Type a number: " num done for ((num;num>=0;num--)); do ...
2
votes
1answer
44 views

Storing one bit of information in user space [closed]

I'm writing a program that collects network data. I need to store one bit of information, a simple yes/no, somewhere so another process may read it. I have several options: writing a 1 or 0 to a file, ...
0
votes
0answers
25 views

Create complex installation script for Linux (Centos)

For deployment of a complex system I would like to create a script that runs all compilations and set up. I am looking for an existing product that interpret installation scenario and performs all ...
0
votes
0answers
43 views

Need to have password coded in script [duplicate]

I have to login many Servers day in day out by supplying passwords manually. Now I want to know or have a script where from I can login to any server without password (I mean to say if the ...