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)

0
votes
1answer
87 views

How to execute shell commands in a loop from within a bash script?

I am new to bash and need help badly. I want to write a script which will run on my android phone & perform the following things: echo "1" > /sys/kernel/mm/ksm/run wait for 2 minutes: then ...
1
vote
2answers
38 views

Else not Executing

In my script, I transform data to a more readable format. But I am having an issue. If no arguments are typed, just the script, I want it to come back "Please enter a filename" which I have done. But ...
0
votes
1answer
30 views

Formating VGA info to conky

I'm trying get conky working on my system, and I'm stuck on how to format an specific shell variable to display my VGA. From shell I get my VGA using: lspci | grep VGA The output: 01:00.0 VGA ...
2
votes
1answer
32 views

How to create a zip of directories -mtime -150

I want to zip the directories, sub directories, files in main and sub directories from today till 150 days ago. I only consider the date of the directories where I am running the command, no matter ...
1
vote
0answers
28 views

Can't get bare-bone simple bash function to work [closed]

I have some tmux scripts in a directory, and I'm trying to make a script to make it easier to call them. Function is below tms() { ~/linux/scripts/tmux-scripts/$1 } This is in my bashrc, I then ...
-1
votes
1answer
46 views

How to edit a file from a script using a loop instead of find and replace with sed? [duplicate]

Here is the sample of the code of what my intent is for such a script: #!/bin/bash Update=$1 if [$Update == Value] then NewValue= $Update vi %s/Value/$NewValue/g > Updatedfile fi ...
0
votes
2answers
45 views

Cannot login after making a service autorun at startup [Debian]

On a normal startup after booting the login prompt appears from where I would login. But after making motion autostart I am unable to login or open GUI because motion is using the command line to ...
-1
votes
2answers
58 views

Shell append string after last match

I would like to insert a string after the last match, example: String to insert after last instance of banana: Orange Input Apple Banana Apple Banana Output Apple Banana Apple Banana Orange I ...
0
votes
1answer
36 views

Auto Download & Untar Script

Looking to write a script for my Linux Server so look for a specific folder name, then wget a file, and untar. Where would I start with this? I know that it has to be written in bash, but I'm very ...
4
votes
3answers
172 views

Bash script: do something one time inside a loop then stop, but continue looping

I have a Bash script that checks my laptop battery and sends me an Android notification (via shuttle, a Bash script I wrote that serves as a cli interface for the Pushbullet API). It works nicely, but ...
-1
votes
1answer
44 views

Whats wrong with the 2nd script?

I am new to linux and scripting. I have some concerns regarding the script below which creates folder per line from file. Folder.list is located in /scripts/ . 1st script works smoothly but the 2nd ...
2
votes
0answers
22 views

How can I tell whether or not I am in a text area?

I am running a Window Manager and am soon getting a Thinkpad x220 tablet. I was hoping to make the tablet a little more functional by having an on-screen keyboard, and I have set it up so I can ...
0
votes
2answers
88 views

How to find out last run time of shell script?

I am trying to find out at what time the shell script ran last time within the shell script. I tried: ls -laru ls -lart but all these commands give me the last modified time and last accessed ...
0
votes
4answers
62 views

Copying Only Directories With Files

I am trying to copy files and the directory it is in to another location. I can find the path like this: find ~/dim_import/* -type f ! -name xdir | cut -d '/' -f 5-10 which outputs ...
1
vote
1answer
63 views

sh - Using Arguments in .profile functions

I want to use an argument in the function I created in my .profile file. I want to ask for input if no argument is given, otherwise set a variable to $1. When I check $1 to see if it is empty, I ...
0
votes
1answer
54 views

How to calculate Swap warning/critical dynamically through script?

I have used SAR in my below script and is trying to run on individual servers for my nagios monitoring. Can someone please suggest how i can get the swap warning and swap critical values in my check ...
1
vote
2answers
98 views

How do I scp a file from server A to server B from cron?

I have a file in server A which I am able to do transfer to server B using scp. I need to do this through a cron entry. server B has a password. How do I perform this?
0
votes
1answer
54 views

Select latest updated file from directory and send it via email

I want to select latest error(timestamp).log file from some directory and send it via email as attachment. What I am trying is: Filename: abc.sh echo 'An error occured' | mutt -s "Logs" -a ...
1
vote
2answers
545 views

Bash script to read file and echo different lines to output files [duplicate]

I have a log.txt file with various lines of strings and information. I want to write a script to read the log.txt file line by line and any line that contains the word debug I want to put that line ...
0
votes
1answer
77 views

/bin/sh script error “arithmetic expression: expecting primary: ” + “ ”

ERROR: ./client-disconnect.sh: 22: ./client-disconnect.sh: arithmetic expression: expecting primary: " + " I just need to know how to fix it. It's for user accounting with OpenVPN. Script ...
1
vote
1answer
28 views

What's the Fedora equivalent of /var/lib/dpkg/info/[…].prerm?

Example file: /var/lib/dpkg/info/util-linux.prerm What's the Fedora equivalent of this file? (Not limited to util-linux - generic question for any package.) Use case: A prerm script is failing. ...
-3
votes
1answer
26 views

Need help running a command based on a file in the directory

I have some scripts setup that I would like a master script to call based on a files appearance in a directory. Basically I have what's show below. Script A uses file a Script B uses file b ...
1
vote
0answers
38 views

Script for changing monitor refresh rate when fullscreen on a specific website.

Premise I recently discovered this website where I can watch legal streaming of plenty of animes. They use a flash player and the CEO said that, for legal reasons, they can't use a HTML5 player. The ...
1
vote
0answers
27 views

-devilspie doesn't play nice with spawning new terminals

I'm trying to configure devilspie so that on detection of opening a certain directory it runs a script to mount that directory over a network. I don't think the script itself is too important but ...
2
votes
3answers
73 views

Split command and arguments, and put into variable in a bash script

I have a script that repeats the same (very long) grep command many times. I want to make the script more readable by cutting the line length, so I tried to put parts of the command into variables. ...
1
vote
0answers
20 views

Creating and mounting partition automtically

I am running raspberry pi on raspbian wheezy, and I'd like to create script that automatically creates new partition on unused area of disk and mountpoints on it so it'll always mount on same ...
0
votes
2answers
69 views

viewing printf after pipe (or subshell?)

Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it. The following script is meant to pipe mount.cifs commands to a while loop that enters ...
4
votes
3answers
486 views

Exiting a shell script with nested loops

I have a shell script with nested loops and just found out that "exit" doesn't really exit the script, but only the current loop. Is there another way to completely exit the script on a certain error ...
1
vote
0answers
14 views

Application started in /etc/X11/xdm/Xsetup can't receive key presses

I'm using xdm (and I'd like to keep it that way) for a project and I need a terminal to run a script before the login prompt. The script requires some user input, however, it doesn't seem to work. ...
0
votes
2answers
46 views

Why Are There Three Processing Running For One Script?

I have the following line in crontab. @reboot /usr/bin/teamspeak3-server_linux-amd64/ts3server_minimal_runscript.sh When I reboot, the script runs (i.e. my Teamspeak 3 server starts) in the ...
0
votes
1answer
72 views

A bash script that can automate git commit message contents

Normally when I commit a change to a submodule in Git (and if that's the only change), I will provide the result of git diff <submodule-name> to the body of the commit message (with ...
0
votes
1answer
20 views

Old file deletion script

I used this script: #!/bin/sh for file in "$( find /var/backup/web2 -type f -mtime +1 -maxdepth 1 -exec rm -f {} \; )" do rm -f $file done exit 0 to delete files older than 24h from fixed ...
0
votes
1answer
18 views

Substituting the value with spaces for a variable in bash script - the correct way

I have a compilation script that can compile the program with and without the debug symbols. I want to ask via bash prompt ( read ) the user to choose whether he wants a debug version or not with ...
1
vote
2answers
61 views

How do i search for certain sections of a file and then extract only relevant information within that section?

So I have a text file that is a server report and has about 1000 lines of information in it. I'm trying to write a script that can search the report for only certain pieces of information I'm looking ...
1
vote
2answers
51 views

Why does trying to run a python executable return ': No such file or directory' after transferring it to server via FTP? [duplicate]

I'm having an issue where when I transfer a Python file to my VPS via FTP and try to run it using ./foo.py I am returned with the error: : No such file or directory. The error seams to indicate that ...
3
votes
3answers
68 views

Converting rows to row groups

Can somebody please help me with the below conversion shell script ? Source File File 1 : for example EXCHANGE_ID : 192, 410, EXCHANGE_DTTM : ...
0
votes
2answers
94 views

Bash script that detects if a file is the correct size

I'm trying to make this bash script dispatch and email when it detects that a certain type of file (files ending in ".gz"), which was last modified 24 hours ago, is below a certain size in a ...
1
vote
1answer
29 views

Application Shortcut To Launch On System Boot

I have a ts3.desktop file in my /usr/share/applications folder that I want to run on system boot. Can you please advise me on how this can be done?
0
votes
0answers
26 views

Can rpm call an external script stored somewhere in the package during installation?

I have a package which is being retooled for in house purposes. Mostly making changes to the configuration files. The files need to be somewhat dynamic so changing the config files at source isn't ...
1
vote
1answer
73 views

Bash script to edit text in csv-format

As part of an inventory bash script I am checking SFP modules and adding them to a .csv-file. The format currently looks like this, with varying lengths: RO01;1000BaseSX SFP;1000BaseSX SFP ...
3
votes
2answers
76 views

check for “errors” or “ORA-”

I want to check for "errors" or "ORA-" in Y.if there is an error then exit Y=`sqlplus -s user/passwd<< EOF exec test_Proc; exit; EOF` if [ echo $Y | awk '/ERROR/ || /ORA-/' ] ; then exit 1 fi ...
1
vote
2answers
66 views

How do I test if my variable is not in a set?

I am trying to modify the bash shell script and need some assistance. I have a directory with a bunch of files. What I need is to go through the files in a loop and if the file name not in a specific ...
1
vote
4answers
152 views

How to use and/or conditional in shell script

I have an if statement in a script. It looks like this: if [ "$a" != "0" -a "$b" != "100" ]; then #some commands here If I'm not mistaken, the line above will work if both conditions are true. ...
1
vote
1answer
325 views

delete multiple remote files with the FTP command

Right now we have a script that uses the FTP mget command to download all the files in a specific location. After after verifying the files have successfully downloaded we run a ftp delete command ...
1
vote
1answer
56 views

Is there a tool that automatically inserts and updates a script header block for e.g. shell or Python scripts?

I found scripts by a former admin who scripted quite nice things with Bash or Python. All his scripts are well formatted and equipped with a always similar looking "script header" or "code header", I ...
1
vote
2answers
41 views

Prevent certain lines of a script to run as root

Suppose I am writing a shell script that requires root privileges to run, for example- #!/bin/sh ip -s -s neigh flush all ufw enable How can I prevent certain lines of code to be run as root, i.e. ...
1
vote
1answer
73 views

Bash script to detect a file modified yesterday and check if its size is above a certain threshold

I'm writing a script to stat all files in a directory, and then find specific files that were created yesterday and tell me if they are larger than a certain size or not. So basically I need this to ...
1
vote
1answer
36 views

UNIX Script not reading the folders with spaces [closed]

I have a UNIX script which is supposed to scan all the folders and return the files older than speciific amount of time. I gave the logic as below, but the script is not able to read the folders with ...
0
votes
2answers
26 views

Unable to perform a simple multiplication in script

I am havingf trouble performing a simple multiplication in my script. while read A B C do tmp=$A\*$C/100 echo $tmp >> out1.txt done < foo.txt foo.txt: 13721725 99 100 ...
0
votes
4answers
49 views

tabs in variable not working

I have this lines that i will insert in a mail called "header". header=" ------------------------------------- Name\tAge\tGender\tAddress ------------------------------------- " Unfortunately, the ...