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)

1
vote
2answers
15 views

Merge PDF document but with conditions

I make bus timetable booklets for drivers every day, and I have 4 PDF files: Special Instruction Sheet (Every day different) Bus daily timetable (which is always different) Bus Assistant daily ...
1
vote
1answer
27 views

KSH script having trouble reading in variables line by line

For starters, I'm not the most advanced scripter. I was asked to create a script that would search through a directory for print files older than 14 days and move them to an archive directory. There ...
23
votes
4answers
97k views

how can I add (subtract, etc.) two numbers with bash?

I can read the numbers and operation in with: echo "First number please" read num1 echo "Second number please" read num2 echo "Operation?" read op but then all my attempts to add the numbers fail: ...
2
votes
1answer
1k views

How to create gcov files for a project in a different dir?

I want to analyze code coverage datas. I want to create gcov files from OpenSSL (and from other projects), but I can only create them in the same directory of the project, and only for the files in ...
0
votes
1answer
22 views

update lines in a file

I have a file,where it has some fields.For example, var One = "fcb"; var Two = "abc"; How can I update/replace these lines using a script? I want to be able to do something like : echo -n "...
1
vote
2answers
24 views

Best way to ensure that a script is run once a period?

I need a certain script to run once a month (others viewing this question may need it to be run once a day/week/year/5-day, etc). I know I can use cron to do so with: 0 0 1 * * ./script.sh But what ...
0
votes
2answers
29 views

SFTP to upload files at cronjob

I want to use SFTP to upload files from A to B. path for A: /tmp/A path for B: /tmp/B server B has own username & password. my cronjob will run every 10 mins to check whether there are new files ...
16
votes
10answers
66k views

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...
0
votes
0answers
34 views

Curl gets 200 OK, while browser shows 503

I have a bash script: code=$(curl -I -s -S --resolve $host:$port:$ip $link | grep 'HTTP/1.' | awk '{ print $2 }') if [ $code -eq 502 -o $code -eq 503 -o $code -eq 504 ]; then /usr/sbin/service ...
0
votes
4answers
56 views

How can I run a command periodically and indefinitely till it's turned off?

I want to run a command every several minutes until I turn it off. After some searching, I found lots of ways of doing the first half (running a command periodically and indefinitely), what about I ...
0
votes
2answers
225 views

How to update three CSV files based on a fourth file

I have four csv files, and I want to update a set of three, based on the values in the fourth file. file_1 contains names. file_2 their numerical ids. file_3 contains ids from file_1 and file_2, ...
0
votes
1answer
464 views

Is there a way of copying only directories and not files? [closed]

I want to copy only directories from a folder on a remote server to my server. Is that possible? Here is the code I have so far but it copies files and folders: scp -rq username@192.168.78.331:/copy/...
2
votes
2answers
255 views

Run a ping command on list of servers and output to a file

I have a file servers.txt on a different server, with list of servers: server1.mydomain.com server2.mydomain.com server3.mydomain.com I want to first download this txt file, ping these servers and ...
2
votes
2answers
3k views

LVM2: Obtaining lv and vg names from path (volume group name and logical volume name)

Let's assume we have lv path: lvpath=/dev/mapper/vg2-Music Than I split lvdisplay -c with cut: vgname="$(lvdisplay -c "$lvpath" | cut -d ':' -f 2 )" lvname="$(basename "$(lvdisplay -c "$lvpath" | ...
3
votes
1answer
45 views

tmux script to launch several commands

How can I write the following in a bash script? tmux # Start tmux session. compass watch /path/to/project1/compass/ # Run the first process. Ctrl + B, " # Split the pane. compass watch /path/to/...
-1
votes
0answers
16 views

How to run a function for a specific received packet? [duplicate]

I am doing an experiment for my master thesis. I want to run a function (e.g. multiply two numbers) when a specific packet is received (e.g. a packet with destination TCP port 6666). For example, I ...
0
votes
3answers
2k views

VLC script on ubuntu server

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout "#transcode{vcodec=h264,vb=999,acodec=mp3,ab=128,...
0
votes
2answers
55 views

How to add users from data in a text file

I am a beginner in linux. I have a question about creating multiple users in linux, but I need a program to work on it. There is a new users txt file, the content is following: adams:5000:Adams, John ...
1
vote
1answer
3k views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
0
votes
2answers
28 views

Passing variables to script [duplicate]

What is the difference between: ./script.sh "$VARIABLE" and ./script.sh ${VARIABLE} Is there any?
0
votes
4answers
1k views

Permission denied when run script via ssh

I wrote script which download via scp and install some packages. SSH keys are added to host and when I run [root@HostB ~]# ./myscript everything is ok and packages are downloaded via scp without ...
-1
votes
0answers
40 views

Need scrpit to run progam with variable files [closed]

Need a script to automate this Move file mv /somedir/(whatever).apk /data/local/tmp/somedir Change Permissions if not change them /data/local/tmp/somedir = rwxrwxr-x /data/local/tmp/somedir/(...
18
votes
4answers
56k views

Confusing use of && and || operators

I was skimming through an /etc/rc.d/init.d/sendmail file (I know this is hardly ever used, but I'm studying for an exam), and I've become a bit confused about the && and the || operators. I'...
3
votes
2answers
60 views

Can you tell if a file has been renamed?

Many tools out there for syncing files aren't quite right for syncing you're home directory. Because of this, and to learn Ruby, I've been working on my own sync tool. An issue I've encountered, ...
-8
votes
1answer
42 views

HOow to run hello world using bash? [closed]

Tell me how to run bash.i am new in this area please help me
0
votes
1answer
3k views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
0
votes
2answers
38 views

cat doesn't join my files when I run inside script

I'm doing a restore backups script, and when I try to join files which are splitted, cat prints that error: cat: fullbackup_mrbsNuevo_15_6_2016.tar.gz.*: No such file or directory The line that ...
1
vote
1answer
46 views

How to compress all files in folder and erase the untared versions via command line?

I have a backup disk containing uncompressed versions of my files that I would like to compress to save space on this disk. The disk (containing files to compress) is full (about 3TB with 17GB free). ...
0
votes
1answer
176 views

Echo semicolon in bash

I am trying to write to a file the following string: 1;2;3;4. The semicolons create problems. I have been able to figure out the following ecamotage to do it: variable='1;2;3;4' echo "${variable//;/\...
1
vote
1answer
248 views

Why is my loop not continuing properly in my rock paper scissors game?

I'm making a bo3 rock paper scissors game. So far I've gotten it to work under every condition except ties. When a tie happens, it's meant to 'remake' that game by just subtracting 1 from I. It doesn'...
0
votes
0answers
25 views

Why is this udev remove rule not working? [duplicate]

Hate to ask this sort of question, but... Device info: udevadm monitor --env UDEV [3048.530438] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6.3 (usb) ACTION=remove BUSNUM=002 ...
0
votes
1answer
136 views

What's wrong with my elif statements in this rock paper scissors game I'm making [closed]

making a rock paper scissors game to learn better bash. For some reason it's not liking my elif statements and I can't figure out why. Also if there are any better ways of doing this let me know, ...
0
votes
1answer
50 views

how to replace special characters in large text file in shell scripting [closed]

I have using for below command but I have replaced special characters some characters is replaced some one not replaced that is my equation. sed "s/\,/\&\#44\;/g" VENKAT.TXT|sed "s/Décor/D\&...
2
votes
3answers
41 views

rename(1)-like script in Perl, but for copying files?

So there's this rename(1) Perl thing. It suits my task precisely, except that I need it to basically cp files instead of mv. How to achieve that? I have quite a few rules of renaming, all expressed ...
1
vote
2answers
63 views

Wait until a process comes back from sleep

script.sh is run by run.sh N times in parallel. For N=1, the script.sh process is set to sleep 30-45 seconds before it actually starts. How can I order ALL script.sh instances for N>1 not to start ...
1
vote
2answers
68 views

Copy files that are created today without FIND command and SFTP to another server

I have a directory with 'n' number of files in it. I am trying to write a shell script which will list only the files created on the particular day the script is running, and will use sftp to move the ...
1
vote
2answers
6k views

how do I run a cron job with a specific user?

My cron and scripting skills are very poor, but I need to run a job every 5 minutes by user 'cpc'. So I created a script and left it at /root. My crontab -e entry about it is: 0-59/5 * * * * /root/...
2
votes
1answer
88 views

Use xvfb to automate X program

I originally posted this question here, but upon second thoughts I decided here was a better place for this. I sadly have to use this proprietary program that bundles a camera driver. I want to ...
-1
votes
1answer
29 views

How to record numbers of array elements based on selection comparision criteria

I have many files which has many 2x2 arrays. In the present example I show only one file (file1) Input file(file1): 1: 6.1703 541.631 46.0391 2: 6.1930 537.446 45.9239 3: 6.1931 177.171 288.579 ...
0
votes
0answers
22 views

Execute custom script when wireless NIC connects to SSID

I have pieced together two scripts that will serve to execute a custom script when my wireless NIC connects to an SSID. Firstly, I will add the following (notice the post-up section): auto eth0 ...
0
votes
1answer
37 views

find: missing argument to '-exec'

this is my first post, as I am completely new to the programming world. Basically I'm taking a UNIX class and I have an assignment asking me to check the size of regular files in my home directory for ...
-2
votes
1answer
28 views

Unix shell scripting select and case statement

1) i want to write unix script which is like this echo "Do u want to check application logs ???" select opt in Yes No do case $opt in "Yes") commmands ;; "No") break ...
1
vote
3answers
2k views

Split XML file into multiple files

I have an xml file that have different nodes, I want to split files like this: <unix> <mm> </unix> <osx> <nn> </osx> When I run the script I want it to make ...
-2
votes
1answer
43 views

Write shell script for logging in servers and run command after logging in

I have wrote a shell script for logging into servers and run few commands to start and stop processes running on it, So I tried below code, but it is showing error, please help me with the script. ...
1
vote
1answer
60 views

Can a Linux server that authenticates against an Active Directory accept public/private keys for passwordless login?

I have a Linux server that authenticates users against an Active Directory. Now interactive logins require username and password and automatic login requires a keytab (Kerberos) for passwordless ...
0
votes
0answers
35 views

wgetting links that are written in script form - not plain html

I use wget to download all the html pages in an online gallery - in order to grab all the links to the full size images as follows: wget --wait=3 --user-agent=Webtography --no-cookies --timestamping -...
1
vote
1answer
36 views

Convert GPS coordinates with bash script

I need to convert to a specific format some gps coordinates which are the output of the exif information of a picture. This is the typical output: exif:GPSLatitude: 10/1, 10/1, 10/1 exif:...
-1
votes
0answers
39 views

File edition after glob function through python

I wanted to find every instances of a file under different directories and search for value 0 in each of those files and replace them with 500. Please find the code below #!/usr/bin/python import ...
0
votes
2answers
35 views

I'm trying to pull all the text past one point in a file and print it on the screen using bash

This is my input and output: cat /home/$USER/Downloads/cudaHashcat-1.37/cudaHashcat.pot | grep : $6$Tgjtsn2v$dT2el6ZxY9ADYl2WlZE6UdCkDyczwztDoXvtym6KEZv6vkZjNHDbTv.vTVHeQSIrt61uWpbD/gisf3bcET8VK.:...
0
votes
1answer
34 views

Read file upon .bashrc startup, based on date

I'd like to put a script in my startup that reads a line from a text file, and echoes this to the screen. However, I'd like a different line from the file based on what day of the month it is. Thus ...