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)

2
votes
1answer
25 views

Dynamic Variable in KornShell Script

This KornShell Script (ksh): envir=Dev eval "${envir}foo=bar" echo "$Devfoo" Output: bar But I will not know what value is assigned to envir variable. So I want to do something like this where ...
11
votes
4answers
11k views

Invert boolean variable

I want to try simple script flag=false while !$flag do read x if [ "$x" -eq "true" ] then flag=true fi echo "${x} : ${flag}" done But when I run it, if I type true, I will see ...
1
vote
1answer
136 views

Startup script with LSB headers not working correctly (dependency problem)?

I am creating a startup script for my Ubuntu 14.04.1 LTS server. The script need to be run after the Rabbit MQ server. The Rabbit MQ startup script says it provides "rabbitmq-server". So I put this ...
0
votes
0answers
67 views

Bash, find and delete old files

Write script for backup files and delete old: #!/bin/sh BACKUPDIR=/var/backups/files ROTATE=1 mkdir -p $BACKUPDIR CURRENT="$BACKUPDIR/`date +%Y-%m-%d`-files.tar.gz" cd /var/ && tar czf ...
8
votes
7answers
2k views

How can I make a script to count up by fives?

I was trying to make a very simple bash script to list all of the multiples of five between 375 and 3500 (375, 380, 385...). One thing that I tried and didn't work is: for i in {375..3500} do ...
1
vote
1answer
60 views

Can I execute a script before every login

I am planning to have a program that will need to connect to a server. I'd like to be able to send a encrypted password to my server. The thing is, I need my decrypting script to be executed ...
2
votes
1answer
28 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 ...
2
votes
1answer
29 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 ...
2
votes
2answers
42 views

Delete Entries in File if the Same Entry Exists in a Master File

I have a JSON master config file whose value may be overwritten by a specific account's config file (also in JSON). The Master file has this structure: { "section1Configs": { "setting01": ...
-1
votes
2answers
44 views

Find file, Edit text within files

Im trying to find a file then edit the text within these files. This is what I have so far, but sadly Im not that well versed... Help Please? grep -rl "wrongtext" ~/Library/Calendars ...
2
votes
2answers
718 views

securely automating a script which requires a key to do its task

I have a script that downloads bank transactions to store in a database. To get these transactions requires a password for each account. The database is encrypted and requires a key to access it. All ...
2
votes
2answers
88 views

Merge two-columns files into one file

I have a bunch of files (file1, file2,file3, ...) with two columns. For example, file1 looks like: 0.12 0 0.32 0 0.42 1 0.23 0 and file2 looks like: 0.34 1 0.55 1 0.31 1 0.99 0 I wonder how to ...
-1
votes
1answer
37 views

How to edit a file from a script using find and replace? [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 ...
3
votes
4answers
379 views

Add path to $PATH if not already in $PATH [duplicate]

I need to add a path in a bash script, but it may be executed several times: export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/bin/:${PATH} I don't want that path to be added over and over. How can ...
3
votes
1answer
94 views

how to compare a decimal value with a integer in shell scripting? [duplicate]

Could anyone please help me for comparing a decimal value with a integer in shell scripting? Example: i=1 j=1.2 if [$j -gt $i];then echo "growth" else echo "None of the condition met" fi Im ...
0
votes
1answer
16 views

Problem with inotify-wait as daemon

I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more ...
2
votes
2answers
5k views

grep output of expect script

I'm trying to run some expect language, and grep/parse the output all in one script. I want to grep the output of and look for "error" (I should note that standard linux commands like awk, sed, grep, ...
0
votes
1answer
56 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
75 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?
-3
votes
0answers
19 views

How to switch 2 scripts based on browser size? [migrated]

I'm new here. I'd like to ask if you can switch 2 scripts using a script? Currently, I have 2 different sizes of banners which are being called using invocation codes. Invocation code for 728x90 ...
3
votes
4answers
738 views

Print a string including single quotes and other special characters

How can I write this with an AIX script correctly? My requirement is to write this command in test.txt: clock=$(prtconf -s | awk '{print $4,$5}') I tried this command: print 'clock=$(prtconf -s | ...
1
vote
2answers
37 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
0answers
17 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 ...
4
votes
2answers
581 views

How can I copy all users .bash_history files into my home directory?

I am running as root. I want to copy all the users on the system's .bash_history files into my home directory. I can do this to combine all of them into one, but then I can't tell who's commands are ...
0
votes
2answers
675 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 ...
0
votes
1answer
43 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 ...
0
votes
4answers
59 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 ...
0
votes
2answers
790 views

Why is my shell script hanging on `apt-get -y upgrade`?

Ubuntu : sudo DEBIAN_FRONTEND=noninteractive apt-get -y update sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo reboot Script is always interrupted after upgrade and then it will stay on ...
1
vote
0answers
26 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 ...
4
votes
3answers
146 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 ...
0
votes
2answers
35 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 ...
0
votes
1answer
28 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 ...
0
votes
3answers
43 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 ...
-1
votes
1answer
43 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
2answers
544 views

Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again

I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
11
votes
4answers
4k views

Using notify-send with cron

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without ...
2
votes
0answers
21 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 ...
1
vote
3answers
2k views

Configure localtime. dpkg-reconfigure tzdata

I'm using this to configure localtime: dpkg-reconfigure tzdata It is ncurses interface. I'm looking for the way to programming this. Is there true way without user ncurses interface? How to ...
0
votes
1answer
2k 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
1answer
47 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
1answer
2k 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
3
votes
2answers
62 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
1answer
56 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 ...
6
votes
1answer
691 views

Can capabilities be used in scripts without setcap'ing the interpreter binary?

Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf. Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
7
votes
3answers
27k views

su options - running command as another user

I was wondering how to run a command as another user from a script. I have the script's owner set as root. I also have the following command being run within the script to run the command as the ...
0
votes
1answer
50 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
708 views

Nmap script execution to detect heartbleed is failing

Wanting to setup Nmap on my Ubuntu 14.04 LTS system to detect HeartBleed vulnerability. I followed the instructions here: ...
1
vote
2answers
196 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
2answers
306 views

ipset not executing from crontab

I have this txt files that contains IPs, one per line of file, that I want to block using ipset. I have this bash script that essentially reads from the plain txt file and constructs an array. Then ...
0
votes
1answer
48 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 ...