Tagged Questions

Questions pertaining to the bash shell: basic functionality, inner workings, interoperability, POSIX-compliance, and scripting. The premier online guide is available at http://wiki.wooledge.org/BashGuide

learn more… | top users | synonyms (1)

0
votes
1answer
27 views

pass command with stdout to a bash function

ok.. this is the deal. i have a bash script like the following. the script is only to show you what i mean .. it may look strang... but is exactly what i need.: #/bin/bash runcommand () { ...
2
votes
2answers
35 views

How to remove 'final blank space' for folder name and file name?

i've 600gb of data's from Mac Users, saved in a disk formatted in HFS+. A lot of folder and file name contain 'final spaces'. I don't know how users inserted them , but the result is that via Samba, a ...
2
votes
3answers
67 views

Bash can't find file after I've moved it

After I move an executable file which I've recently executed (or more commonly, after I uninstall something from somewhere and install a different version somewhere else), bash can't find it, even if ...
-1
votes
1answer
27 views

Why does “cp -Rp ~/foo /Volumes/KINGSTON” give “cp: chflags: /Volumes/KINGSTON/Proj/Proj/Color.h: Invalid argument” [closed]

This is on Mac OS X Lion, and I use the following to back up a project folder cp -Rp ~/foo /Volumes/KINGSTON or cp -a ~/foo /Volumes/KINGSTON The -p or -a is so that the timestamps of the files ...
1
vote
3answers
27 views

Script to open multiple gnome-terminals with individual telnet sessions

I'm just curious if this is possible. I'm working with dynagen/qemu rather frequently (CCIE training), and would love to be able to run script 'x' to open 10 windows for me, all telnet'd to ...
9
votes
2answers
109 views

What is the difference between “sudo -i” and “sudo bash -l”

There is a recent question regarding multiple sysadmins working as root, and sudo bash -l was referenced. I searched for this on google and SE, but I don't understand the difference between sudo ...
-1
votes
2answers
24 views

linux script - find java process and restart it if it is more than 80% Mem High

I want to put in crontab a shell script that will monitor the java process and if it's the memory is more than 80% then I want to restart it. can any one help? Thanks!! Elad.
3
votes
3answers
43 views

Running bash script with php under lower priority or limit CPU

I have a bash script which runs a set of php scripts. When it runs it takes an hour and pegs the CPU at 95-99%. This causes our lamp stack (mainly the apache process) problems and our website on the ...
1
vote
1answer
54 views

Linux execute permissions

-rw-r--r--. 1 myusername developers 169 May 17 09:01 build.sh Why is it I can execute the build.sh script from the command line if it does not have execute permissions but when crontab tries to ...
1
vote
2answers
19 views

Checking if a ruby gem is installed from bash script

I need to, from a bash script, check to see if certain Ruby gems are installed . I thought I could do something like if ! gem list <name>; then do_stuff; fi but testing on the command line ...
0
votes
3answers
63 views

remove line break using AWK

I am facing some problem regarding my bash script. Below is my bash code : #!/bin/bash cd /root/Msgs/TESTNEW/new file=myfile.txt var1=$(awk '(NR==30){print $2}' $file) var2=$(awk 'NR>=38 ...
2
votes
2answers
53 views

Perl command line + add PATH before string in file

I want to add the PATH - /usr/local/bin/perl befpore string in the file by perl command line ( the perl command line must be in my bash script ) , I have solaris machine the target to add - ...
0
votes
6answers
63 views

What does passing the -xe parameters to /bin/bash do

Exactly what the title says. I'm not having much luck finding the proper documentation to see what -xe does in the following use case: #!/bin/bash -xe what do those parameters do and where it is ...
1
vote
0answers
37 views

Documentation for bash arguments [closed]

Possible Duplicate: What does passing the -xe parameters to /bin/bash do Where is the best place to read documentation on what parameters that are passed to bash such as -x and -e are? I ...
1
vote
1answer
37 views

logging with named pipes

I have a lot of code I need to daemonize that prints to standard out. I am thinking of using the following shell script to create a named pipe so I can nohup a process while redirecting its output to ...
1
vote
1answer
46 views

copy and replace to folders to another fastest way - linux bash

I have a three folders: core, project and merge with many files inside. I want to delete all files and folders (including dot files) inside the merge folder, and then copy all files (including dot ...
-1
votes
1answer
35 views

Bash installing script that fits all common Linux flavors

I was asked by my boss to make a bash script that could install Apache, PHP and MySQL (AMP) binaries in a Linux box (just some common linux flavors). Compile and install all by the sources ...
1
vote
2answers
35 views

Be able to pull from git without password on login or just run keychain which does it for me

I need to pull from Github all the time and I have a passphrase, but it's a pain, so I typically run... ssh-agent bash ssh-add ~/.ssh/id_rsa <prompt and give passphrase> git pull ... And ...
3
votes
1answer
42 views

Kill process group not working

I'm on Debian GNU/Linux. The man page for "kill" says I can use negative PID value to kill process group, but when running on command line, it does not work: $ /bin/kill -9 -21581 /bin/kill: invalid ...
0
votes
1answer
28 views

pgrep/pidof usage for complex process names?

I am trying to use pidof or pgrep to be able to send a HUP to a process in my system. The problem is that I only want to kill the process with a precise parameter. This is the output of 'ps awx' ...
0
votes
2answers
52 views

expect + how to install expect on solaris

subject - install expect on solaris in order to write expect scripts details from my machine: uname -a SunOS 5.10 Generic_139555-08 sun4v sparc SUNW,Netra-T5220 I installed Solaris machine ( ...
2
votes
1answer
51 views

Ubuntu freezes when I run “ps” or “top”

Ubuntu 11.10 Bind9 (not working, won't accept connections) (named-checkconf and named-checkzone both work) OpenVPN (community edition) (working correctly) (bridged mode) PHP5 & PHP5-gd Mysql5 ...
1
vote
2answers
47 views

changing directory in bash script

I have the following script: cd "/usr/local/bin/" /sbin/startproc ./program1 I have a license in the /usr/local/bin directory and if the program isn't started from there it won't launch ...
-3
votes
0answers
37 views

How can I add a user to ubuntu and apache (from xampp) using a sh script?

I found this script here: #!/bin/sh user=$1 #first argument apache="www-data" passuser=$2 # second argument newpasswd=$(perl -e 'print crypt($ARGV[0], "S@LtStR!Ng")' $passuser) ...
0
votes
1answer
37 views

Waiting until TCP socket is available in bash

Helli, I have a script that waits some time until a machine (being provisioned) comes up and then it connects to ssh and executes something. I use "sleep" for that. I would like change my script to ...
2
votes
2answers
60 views

BASH Scripting, su to www-data for single command

I am working on automating the creation of subversion repositories and associated websites as described in this blog post I wrote. I am running into issues right around the part where I su to the ...
2
votes
2answers
44 views

perl + Match last number in file and reduce it by one

I want to add the following perl command in my bash script please advice how to change (reduce by one ) the last number that start with "+" character in file with perl ? Example of original file ( ...
0
votes
1answer
31 views

Whats the best way to strip grave accents from bash scripts

I have a bash script which runs as root: #!/bin/bash /var/bin/svn_co -h $1 >> /var/log/svn/status.log If the following should somehow occur, I'm in trouble. /var/svn/hooks.d/post-commit -h ...
1
vote
4answers
28 views

Stripping “extra spaces” in du -sk for bash script?

I am trying to use du -sk to get the size of two folders dirsize_temp=`du -sk /folder/path/here` and then an if statement to compare the sizes. The only issue is that when you run the command, it ...
0
votes
1answer
52 views

Syntax error near unexpected token `fi'

I have been trying to write a while loop bash script that will check the size of two directories, and echo that out to a text file in the www folder. After my while loop stubbornly refused to work, I ...
0
votes
2answers
49 views

Recursive deletion of files (bash)

I'm familiar with how I would tackle this with PHP, however I'd like to get some more practice with bash scripting. The task is to delete all files in a folder, which itself contains subfolders ...
0
votes
1answer
79 views

Nagios plugin script not working as expected

I have modified an off-the-shelf Nagios plugin perl script to (in theory) return a one or zero according to the existence, or not, of a file on a remote linux server. The script runs a remote ssh ...
0
votes
0answers
47 views

Permit www-data to run ONE svn hook (bash) as root

A quick overview to my structure: /var/bin/ Dedicated server bash scripts to manage server /var/svn/[domain.com]/ SVN repositories directory /var/svn/hooks.d/ SVN hooks (each domain is symbolic ...
1
vote
1answer
45 views

placing shell script under systemd control

Assuming I have a shell script like this:- #!/bin/sh # cherrypy_server.sh PROCESSES=10 THREADS=1 # threads per process BASE_PORT=3035 # the first port used # you need to make the PIDFILE dir and ...
2
votes
3answers
40 views

Bash function, return value and error handling

I am trying to wrap my head around Bash, and think I have gotten pretty far. What I really don't understand yet is the error handling... I have the following script: set -e set -u ...
1
vote
2answers
74 views

BASH: Bind Program's Existance to Another Program

I want to create a script that runs two programs. That part's simple, but there's a catch: I want to kill the second one if the first one exits. How can I do that? Edit I tried killing the program ...
1
vote
0answers
42 views

Autocompletion, history and scrolling in Byobu

I am using an Ubuntu server with Byobu. For some reason, the tab key writes a tab instead of completing commands and paths. Top arrow writes ^[[A instead of the command history. Scrolling writes ^[[B. ...
1
vote
2answers
41 views

How to manipulate accented files on Unix?

On our CMS that went through many versions and hosting platforms, we just came across an accented image file that would not work from it's url. So I ssh'd onto the box and tried to rename it. ...
2
votes
3answers
103 views

Reading variable from the memory

I have a simple script that reads user's input (password) and save it to a variable read -s -p "password: " PASSWD; printf "%b" "\n" Apparently this is not secure as it's stored in a clear text in ...
0
votes
1answer
58 views

Linux bash: No such file or directory message for existing file

I have a strange error occurring on one of my servers - despite a file existing, I cannot run it: This is not limited to this particular program or to the user. It also happens when I try to run ...
0
votes
3answers
58 views

In a shell script, perform different actions depending on the file on a another server (web accessible)

I've been having trouble with firewalls lately on a few different servers. And im wanting to create a script that will run once every hour or so, and check a file on an external server and execute the ...
-1
votes
1answer
26 views

how to connect jconsole to compiere jboss server using bash script?

Is it possible using bash script to connect to jboss server instance shown in jconsole?
2
votes
1answer
33 views

Disable networked tab completion with bash

Networked applications like rsync and scp can tab complete when they are enabled with bash. But what if you want local tab completion without remote tab completion? Is it possible?
0
votes
1answer
42 views

rsync not working - want to copy only certain subdirectories and files

Hi let's say I have a directory like this: / my_work /dir1 keepdir1.ddd keepdir2.ddd file.cfg (lots ...
3
votes
2answers
54 views

SSH Pipe File and Execute

I am attempting to execute a binary on my ssh server as soon as I log in. However I may want to push the update of my binary with a single ssh login and execute aswell. My current process for do this ...
0
votes
1answer
27 views

Pass a String to a Command that is Expecting a File

I have a command line program that is expecting to be passed a configuration file e.g. sphinx --config /some/config_file I'm calling this command from inside a ruby program where I'm currently ...
1
vote
3answers
108 views

sed not working in linux centos, ubuntu,

I have a simple script that gives me some values from a file. I am using sed to get that vaules (syntax is given below). these commands were working fine till yesterday. but now I'm not getting any ...
-1
votes
0answers
31 views

bash + count token in parameter [closed]

my num_of_token parameter is set to: num_of_token="1 2 3 4 5" my question - is it possible to do as the following below with one line? So setting the "num_of_token=( $num_of_token )" will be in ...
0
votes
2answers
53 views

linux + bash + export parameters in to a new file from data file

I have Linux machine red-hat 5.1 and I ask the following question my target is to create new output_file.txt file from answer_file.txt according to data_file.txt as we see here I run first the ...
2
votes
2answers
72 views

Deleting folders with rsync “move”?

rsync can be coaxed into moving folders very similarly and superiorly to traditional mv with the following options: rsync -axvvES --remove-source-files source_directory /destination/ However one ...

1 2 3 4 5 25