bash

sh/expect/sudo/screen all needed together in one command.

What I need to have happen: PHP needs to launch an server app which has root permissions running in the background. All of this should be silent. -Sudo is needed to allow php to perform an op that requires root permissions. -Screen is required to allow the app to run outside the scope of the webpage which started the process. -Expect ...

exec line from file in bash

I'm trying to read commands from a text file and execute each line from a bash script. #!/bin/bash while read line; do $line done < "commands.txt" In some cases, if $line contains commands that are meant to run in background, eg command 2>&1 & they will not start in background, and will run in the current script context. Any...

Init.d script hanging

I have an init.d script that looks like: #!/bin/bash # chkconfig 345 85 60 # description: startup script for swapi # processname: swapi LDIR=/var/www/html/private/daemon EXEC=swapi.php PIDF=/var/run/swapi.pid IEXE=/etc/init.d/swapi ### BEGIN INIT INFO # Provides: swapi # Required-Start: $local_fs # Required-Stop: # Default-Start: 3 4 ...

ssh bash completion file

for git I use this bash completion file http://repo.or.cz/w/git.git/blob_plain/HEAD:/contrib/completion/git-completion.bash you know a good bash ssh completion file? // or other goods bash completion files ? ...

Getting text from inside an HTML tag within a local file with grep

Possible Duplicate: RegEx match open tags except XHTML self-contained tags Excerpt From Input File <TD class="clsTDLabelWeb" width="28%">Municipality:&nbsp;</TD> <TD style="WIDTH: 394px" class="clsTDLabelSm" colSpan="5"> <span id="DInfo1_Municipality">JUPITER</span></TD> My Regular Expression (?<=<span id="DInfo1_Municipal...

Handling integer out of range in bash

I have collected vmstat data in a file . It gives details about free, buffer and cache . SInce i'm interested in finding the memory usage , I should do the following computation for each line of vmstat output -- USED=TOTAL - (FREE+BUFFER+CACHE) where TOTAL is the total RAM memory and USED is the instantaneous memory value. TOTAL memory ...

Bash Script to Extract split archive files using rar

Here's what I want to do: I have thousand of split rar archives on folder name Archives. Name of the files 0001.part1.rar 0002.part2.rar 0003.part3.rar etc. read 0001.part1.rar create a directory based on prefix of the file above e.g. 0001 move all files with the same prefix on the directory created above. Extract the files within ...

Getting a audio feed from my dailup modem

My linux powered laptop still has a dail-up modem. Is it possible to interface with the phone line through my modem. Using bash or ruby, ( or something else, if I really have to) I would like to record and maybe even and make and receive calls. Can this be done? and if so where do I start? ...

I want a to compare a variable with files in a directory and output the equals

I am making a bash script where I want to find files that are equal to a variable. The equals will then be used. I want to use "mogrify" to shrink a couple of image files that have the same name as the ones i gather from a list (similar to "dpkg -l"). It is not "dpkg -l" I am using but it is similar. My problem is that it prints all the...

Creating a shell script to run Java program

Hi I used a shell script to run a Java class. My script contains #!/bin/sh java -jar jobs/job.jar These are my failed attempts to run it. [root@]#sh testapp.sh Unable to access jarfile jobs/job.jar if I just do this at the command line it works fine [root@]#java -jar jobs/job.jar thanks. ...

How to cat two files after each other but omit the last/first line respectively?

I have two files I want to cat together. However, the last line of the first file and the first line of the last file should be omitted. I am sure this can be done in a UNIX shell (or rather, Cygwin). But how? ...

Launching an independent process from php (via httpd)

Hi, i'm trying to spawn a daemon-like process from php on a unix environment, keep the pid for reference and keep it completely independent from httpd processes. This is useful for controlling middleware applications from administrative backoffices. I want to keep it generalized to reuse for any command, i don't want to write a .sh for ...

Quoatation escaping -- rsync from bash

I normally work these things out reasonably quickly, but this one is a headache. I have a shell script that loads some info about where to connect to and how from a text file, this is done using the read command. This works. It stores the arguments to be sent onto RSync in a variable call $rsyncargs. I want to use the RSync arg -e whic...

How to check if a variable is set with bash?

How do I know if a variable is set in bash? For example, how to check if the user gave the 1st parameter to a function? function a { ?? if $1 is set } ...

Hide variable application result from bash output

Hi Guys. I am trying to create a script that will run wget to a few sites and check if we receive a 200 OK from the site. My problem is that the result of wget application is shown in the stdout. Is there a way I can hide this. My current script is: RESULT=`wget -O wget.tmp http://mysite.com 2>&1` Later I will use regex to look for...

jdoc/pydoc/rdoc for bash?

Is there a jdoc/pydoc/rdoc style inline documentation system for bash? I have a library of bash functions that could really use some nice inline docs that I can convert to HTML for easy reading. ...

How to parse of EXIF time stamps with Bash script

As a bash script rookie, detailed answers would be appreciated. :) I am trying to write a bash script that parses JPEG EXIF time stamps output from the exiv2 commmandline utility, which gives me typical output like: Image timestamp : 2010:07:27 17:38:52 Is there a way to parse the time stamp so that its components, like year, mont...

unix bash command

How to write a bash command that finds all files in the current directory that contain the word “foo”, regardless of case? ...

HowTo view text file from the bottom on *nix?

Hi. I'm looking a simple command, like $ less -{view_from_bottom_of_the_file_option} filename or $ vi -{start_viewer_from_the_bottom} filename viewer, editor - what ever. Thanks. ...

Best(?) way to make a popup menu for semi-portable shell scripts?

Basically I would love to say: echo `grep ^foo /usr/share/dict/words | popup_menu` ...and have some type of keyboard navigable menu popup or selection tool, very similar to how vim's ":Explore" mechanism works. Extreme bonus points for "easy and works pretty much everywhere with standard tools" Also acceptable is "needs some sort ...