Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

2
votes
1answer
954 views

How to use kdialog progressbar from a Bash script when the bar was initialized in another script?

Here is an example of how to use the kdialog progressbar. It works. dbusRef=`kdialog --progressbar "Press Cancel at Any time" 10` qdbus $dbusRef showCancelButton true until test "true" = `qdbus ...
2
votes
2answers
248 views

ksh + delete number from string

the string IP include some IP address numbers as the following example echo ${IP[*]} 192.9.200.1 192.9.200.2 192.9.200.3 is it possible to remove some IP address number from the list ( using ksh ...
2
votes
2answers
3k views

How to find files by the time in their filename? [duplicate]

We have a directory contains files which contains time in their filename ./test.2013-06-11_06-01.gz ./test.2013-06-12_01-01.gz ./test.2013-06-13_03-01.gz ./test.2013-06-14_03-01.gz ...
2
votes
2answers
506 views

Directories are listed twice

I have something odd. I creates some directories using a very simple script : ... create all directories ( running under a user that has the correct rights ) e.g : mkdir -p ...
2
votes
1answer
1k views

How to open and work with terminals using bash script?

I need to open four terminals each will then connect to four different remote pcs and open specific directory locations on those pcs. Each terminal will be opened in different locations on my pc's ...
2
votes
1answer
4k views

Ssh to a box, run a command, output data to a file, then move on to the next IP adress [duplicate]

I want to run a script from my Jump server, have it SSH to a server, then run a command (like rm <file>, top or ls -lsa) then take that output and put it in to a file on my Jump server then move ...
2
votes
1answer
185 views

Checking if a passphrase is able to decrypt symmetrically encrypted files

I have about twenty files symmetrically encrypted with CAST5. I have a single passphrase that is meant to work with all of the files and I wish to confirm that it does. I wrote a script to perform a ...
2
votes
1answer
61 views

What is happening when a script encounters an error in one of the commands?

I used alien to convert an RPM to a .deb. I did NOT use alien's script conversion; I'm converting by hand. Indeed, the script did barf on some non-compatible syntax. My question is NOT about how to ...
2
votes
6answers
1k views

extract a file from jar file and get the diff

In real world I have a xsd in a jar file across various releases I am trying to check whether xsd has changed across releases 10.x.y.z to 11.a.b.c I have different release directories which are read ...
2
votes
1answer
3k views

Run expect script from other shell

My target is to create the /var/tmp/add_user.bash script from /var/tmp/create_script_add_user.bash script and run the expect script (add_user.bash) from create_script_add_user.bash script. The ...
2
votes
1answer
402 views

Script to send mail if there has been no entry in a log file for a certain amount of time

I am new to shell scripting. How would I write a script which can send an alert mail if there is no entry in the log file for more than 3 hours.
2
votes
1answer
394 views

perl + combine exec command with perl one liner line

I have the following short perl script rename.pl. How can I translate this script to one liner perl syntax? And how to combine the perl one liner in find command? rename.pl #!/usr/bin/perl $op = ...
2
votes
3answers
550 views

Remove Linux shell script stuck

This script should remove the contents of the dustbin directory. If the -a option is used the script should remove all files from the dustbin. Otherwise, the script should display the filenames in ...
2
votes
1answer
8k views

How to debug csh scripts?

My lab uses csh scripts to run jobs. It is usually difficult for me to debug a shell script, so I'm wondering if there is a csh debugger I can use. I know there are some flags like -x or -v that can ...
2
votes
1answer
993 views

How to get the PID from a spawned process in expect?

Example: In a shell script I open a SSH tunnel whit this: /usr/bin/expect <<EOD set timeout -1 spawn ssh -fNL localhost:1873:localhost:873 HOST expect "*?assword:" { send "$SSHPASS\r"} sleep 2 ...
2
votes
2answers
3k views

Sharing Variables across sub shell scripts

I have a Main shell that runs a profile, The profile contains some variables such as Count. When I call the main shell, it loads the profile and then call another shell script. I want that inner shell ...
2
votes
1answer
173 views

How to have find only search for files in changed directories?

Currently I'm repeatedly doing a 'find' that's too slow. I'm searching for non-hidden executable files within "$root", excluding "$root/bin": find "$root" -type f -perm -o+x -not -path "$root/bin/*" ...
2
votes
2answers
930 views

Search and replace with sed

Last week I accidently externalized all my strings of my eclipse project. I need to revert this and my only hope is sed. I tried to create scripts but failed pathetically because I'm new with sed and ...
2
votes
1answer
1k views

How synchronize two disks (or folders) using symbolic (or hard) links (like rsync)?

I'm searching a tool or a shell script or another program to synchronize two or more folders or disks. But it differs of rsync tool, because, I don't want to duplicate the missing file, but do a ...
2
votes
1answer
529 views

Default fedora 15 install, how do you get a network drive to mount after login?

I am running a default fedora 15 install. My goal is to have a couple of network drives get mounted right after the user logs in graphically (not via ssh). The script I want to execute is basically ...
2
votes
4answers
17k views

Executing a shell command from PHP with shell_exec

Included in my thesis is to create an administration interface, in which an administrator can approve users whom have asked for access to use OpenNebula. Upon approval the users should be added to ...
2
votes
2answers
942 views

Create a new file by removing the new line character at the end of file

I have a flat file which contains the following data records between H: and T:. H:20050427 HEADER RECORD 0000000 00000 000000000 123456 00 654321 DATARECORD 0000000 00000 000000000 123456 00 654321 ...
2
votes
1answer
163 views

Where are the program calls of the boot process stored

I just wrote a little program which logs all calls of bash during the boot process. This is a part of the output produced: (root) '/bin/bash-' '-c' 'gzip -d -c ...
2
votes
1answer
1k views

Attempting to update Amazon Route53 using a script, but domain is not being updated

I have several Amazon EC2 instances, running Ubuntu 10.04, with which I'd like to use Amazon's Route53. I setup a script as described in Shlomo Swidler's article, but I'm still missing something. ...
2
votes
1answer
34 views

Adding folder name to .zip files inside it

I have file1.zip, file2.zip, etc. in folder called folder1. have similar folders folder2, folder3, etc. I need to add folder name to each .zip file inside these folders. So, files inside folder1 ...
2
votes
2answers
44 views

How to ensure echo into a file has been flushed? [on hold]

I have two co-operating programs X and Y running on the same system. X some times uses Y to calculate some information. I use file based communication between the programs. When X wants Y to compute ...
2
votes
2answers
53 views

SOLVED: Shell Script cant run man command

I have a script that runs commands & takes a screen shot. I want the man file to display & grab a screen shot of it. My script works for the commands alone but if I add "man " before the ...
2
votes
1answer
83 views

ksh: for loop to loop through files in a particular directory

schema_dir=schema_app for SCHEMA_CHANGE in $schema_dir/* do so my pwd is /A/B/C/scripts within which I have subdirectories (schema_app, schema_data, etc). I want a for loop to run through the files ...
2
votes
1answer
88 views

.profile is written in shell script — can I instead make my system understand that I want it to execute a Python script instead?

I get Python. I don't get shell script. I could learn shell script, but I would rather not if I can use Python in its place. A good place for me to start would be the .profile script. Currently, for ...
2
votes
2answers
82 views

Insert text in specific lines of a file? with special characters

i know this has been answered several times, but i can't figure out how to use it for my project. i have several php files and want to add a new string between line 11 and 12. this is the string i ...
2
votes
1answer
48 views

Share environment variables with www-data

I have a set of environment variables, which is created with a shell script config called from my ~/.bashrc. Having a new user www-data running a local webserver (with lighttpd), I need it to benefit ...
2
votes
4answers
76 views

Execute Linux command only if column in CSV file has a value greater than 1

I am trying to figure out a way to execute a Linux command only if a specific column in my CSV file has a value greater than 1. Sample CSV file: Item,Quantity Pen,1 Pencil,1 Stapler,3 ...
2
votes
2answers
58 views

Add Filename as first line of file in shell script

Hello and thanks in advance. I need to take a file, insert the filename as the first line of the file, then move to a different name. Here's the wrinkle. I need to grab the oldest file in the ...
2
votes
1answer
30 views

Regex to match = followed by a newline so they both be deleted

I am working with the raw source content of a mail.app message in OSX, but results it gives me the text in quoted printable MIME Email encoding. so I need to remove all those strange characters to get ...
2
votes
2answers
119 views

grep -E-f to capture matching ip-addresses in two files, and , print or echo result of each iteration, xx.xx.xx.xx found or xx.xx.xx.xx not found

Having one short list of few hundred ip addresses in file1, and want to identify if any of these ip addresses are missing from the master list, file2. Looking for an output > redirect to a file that ...
2
votes
2answers
27 views

Forcing the expansion of a global alias in part of a word

I have a couple of scripts /tmp/foo/bar.sh and /tmp/foo/baz.sh, the look like this: # /tmp/foo/bar.sh alias -g __FILE__='${(%):-%x}' alias -g __DIR__='${${(%):-%x}%/*}' printf "sourcing %s\n" ...
2
votes
1answer
28 views

Portable way to customize executable called by script

I have a script that I need to instrument. Suppose it calls a foo program. I can define foo function and export it to sub-shell, thus providing instrumented foo call. This works only if script ...
2
votes
1answer
79 views

How can I get the correct end time of a nohup command?

#!/bin/sh set -x echo "Starting Time at "`sshpass -p xxx ssh -o StrictHostKeyChecking=no UN@IP 'date'` nohup ab -n 20000 -c 70 https://xxx.xxxxxx.com/xxx/xxxx/new.jsp & echo "Ending Time at ...
2
votes
1answer
73 views

Conditional Execution - Launching Persistent Sub-Processes and Coroutines

Conditional execution is used in Bash to control the flow of a script on the basis of the exit status of a subprocess. However, there are situations when a subprocess (application) is launched in the ...
2
votes
2answers
44 views

Help required to execute shell script

I need to write a shell script to see if the ADM Process is down we need to get an alert via email. I have done that using the script below. It is working fine if we have installed one ADM server on ...
2
votes
1answer
33 views

Waiting for two events

I have the following requirement: I have a script executing every N hours which downloads a file via wget, and then does some processing (outputing results to several files). Once this is finished, it ...
2
votes
1answer
44 views

Confine the directories in which a script will act

For example I have a script looks like: for i in */*/ do cd $i cp POSCAR.ideal OSZICAR .. cd .. rm -r */ cd ../; done to remove subfolder of a folder, however with a bit of uncautious, for ...
2
votes
1answer
148 views

Rsync backup script for multiple servers

I have simple script that backing up data from remote server via ssh using rsync. I have external config file for that. In this config file I have variables: OPTIONS, REMOTE_IP, SOURCE and ...
2
votes
2answers
238 views

Copying latest modified file from multiple directories

I have directory structure adc/asd/abc.20150918_150635.gz, adc/asd/abc.20150921_140748.gz .... (where .gz file names contain time stamps of its creation). Many other directories similar to asd are ...
2
votes
2answers
38 views

How can I send multiple options to one variable

I am running a loop for an array of variables that generates three more variables. i.e for foo in ${bar[@]}; do bar1=$(echo $foo | awk '{print$1}'); bar2=$(echo $foo | awk '{print$2}'); ...
2
votes
4answers
86 views

zsh: map command to array

suppose you have an array a=(foo 'bar baz') is there a more obvious way to apply a command/function to every array element and save the resulting strings into another array than this: b=() for e in ...
2
votes
1answer
41 views

Manipulating RGB values in PNG from command line

I'm looking for a command line tool/script which allows you to balance the colors in a PNG - similar to the "Adjust Color Balance" effect in Gimp (Colors > Color Balance...). Something like this ...
2
votes
1answer
448 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
2answers
47 views

Shell script - text processing help

I want to create a ldif modify file to update the users on LDAP. I have an input file(alluserdns.ldif) with list of all Dn entries in ldap: dn: cn=testuser2@abc.com, ou=persons,ou=pp,dc=abc,dc=com ...
2
votes
1answer
205 views

SSH command not exiting properly [closed]

I wrote a script that SSH to remote servers in loop and run a command, it gets hung after running on last server.Here is my loop script - cat server | while read serName do ...