bash

Running C++ CGI Script As Background Process?

Hi, I'm working on an audio encoder cgi script that utilises libmp3lame. I'm writing in a mixture of C/C++. I plan to have an entry-point cgi that can spawn multiple encoding processes that run in the background. I need the encoding processes to be asynchronous as encoding can take several hours but I need the entry-point cgi to retur...

Linux command to do wild card matching

Is there any bash command to do something similar to: if [[ $string =~ $pattern ]] but that it works with simple wild cards (?,*) and not complex regular expressions ?? More info: I have a config file (a sort of .ini-like file) where each line is composed of a wild card pattern and some other data. For any given input string that ...

Emulate subwcrev when using git-svn

I use git-svn to interact with an existing SVN repository that contains some C++ projects. subwcrev.exe is used as a pre-build event to update some strings in a C++ header (svnversion.h). These strings get hardcompiled to form some version information for the resulting binary. Since subwcrev requires .svn metadata to work, the pre-build...

Parsing json with sed and awk

I'm trying to parse json returned from a curl request, like sp: curl 'http://twitter.com/users/username.json' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' I have it set working where it splits the json into fields, i.e. the above returns % ... "geo_enabled":false "friends_count":245 ...

bash script to rename all files in a directory ?

i have bunch of files that needs to be renamed. file1.txt needs to be renamed to file1_file1.txt file2.avi needs to be renamed to file2_file2.avi as you can see i need the _ folowed by the original file name. there are lot of these files. ...

Run a list of bash scripts consecutively

I have a load of bash scripts that backup different directories to different locations. I want each one to run every day. However, I want to make they don't run simultaneously. I've wrote a script that basically just calls each script in succession and sits in cron.daily, but I want a way for this script to work even if I add and remove...

Unix Bash rename files using a regex.

Hi everyone! I would like to rename all files from a folder using a regex(add a name to the end of name) and move to another folder. It my opinion, it should be looking like this: mv -v ./images/*.png ./test/*test.png, but it is not working. Can anyone suggest me a solution? Thanks in advance! ...

How do I always answer No to any prompt with a bash script?

I have a program that runs and asks users certain questions. I want to automate it so that every question is responded to with No. ...

How to substitute a string in bash script

Note: Bash 3.00 How to substitute this example string 123456789, to look like 123-456-789 #!/bin/sh # trivial example read number; # monotically substitute '-' into string after first three and dix digits ...

How do I check the exit code of a command executed by flock?

Greetings all. I'm setting up a cron job to execute a bash script, and I'm worried that the next one may start before the previous one ends. A little googling reveals that a popular way to address this is the flock command, used in the following manner: flock -n lockfile myscript.sh if [ $? -eq 1 ]; then echo "Previous script is s...

Why does my process counting script give false positives?

I have the following bash script, that lists the current number of httpd processes, and if it is over 60, it should email me. This works 80% of the time but for some reason sometimes it emails me anyways when it is not over 60. Any ideas? #!/bin/bash lines=`ps -ef|grep httpd| wc -l` if [ "$lines" -gt "60" ] then mailx -s "Over 6...

Help me decode this javascript which generates a passsword based on a master password and a website's name

Hi all! There's a website that generates a password by joining a master password with the website's name (e.g. master password=abc and site=google) then hashing that with SHA1 and then coding the resulting hash with Base64. I've been trying to implement that in Bash, but I can't. I mean I can but my results are extremely different from t...

command line byte sequence

How do you express a byte sequence from the command line? i.e like you would in PHP with the following: <?php echo "\xC2\xA3" usage: for passing a Unicode string to a script or program. The above example is the UK pound sign "£" ...

Bash Script - Read Binary File

I'm new to scripting, but I have a lot of experience programming in languages such as C# and Java. I have a file that contains binary data. I want to write a Bash script that reads the year, month, and day contained in that file so I can sort the associated MOD files into folders according to the date they were recorded. I'm having trou...

Why is my Bash script adding <feff> to the beginning of files?

Greetings, While I've gotten many answer off this site, this is my first question, and I'm kinda excited about it... :) I've written a script that cleans up .csv files, removing some bad commas and bad quotes (bad, means they break an in house program we use to transform these files) using sed: # remove all commas, and re-insert t...

Running Shell scripts through java

So I have a java class that takes individual commands and puts them into the shell through the Runtime and Process objects. My problem is that I can run a command like: $ls /users/me/documents and it will work, but $cd /users/me/documents $ls still lists the root. Obviously the Process and runtime objects don't keep track of whe...

Cannot SCP a path with spaces from bash script?

I have a bash script which generates an SCP command to execute. The relevant parts of the code look like this: echo $COPY_CMD $COPY_CMD My output looks like this: rascher@localhost:~/Desktop/video_final$ ./xfervids.sh scp "/media/My Book/PhotosVideos/Videos/18May2008Download/SD_VIDEO/PRG001/MOV056.MOD" [email protected]:./video...

Firefox: BitmapData Handle?

Hello all, I have heard that it is possible to get a bitmap/image handle of the webpage being viewed on a firefox browser. I have been researching for a bit and couldn't not find anything. So I am hoping if anyone knows how to do this, preferable via the command line (bash, any other shell on Linux). To be honest, any browser that I c...

Bash: Convert non-ASCII characters to ASCII

How can I convert a string like Žvaigždės aukštybėj užges or äüöÖÜÄ to Zvaigzdes aukstybej uzges or auoOUA, respectively, using Bash? Basically I just want to convert all characters which aren't in the Latin alphabet. Thanks ...

Include one file to another

I'm looking for very simple template script for building JS files. It should do only one thing: include one file to another. Template (main.js) /*> script.js */ var style = "/*> style.css */"; script.js var my_script; style.css html, body {margin:0; padding:0} .my-style {background: #fffacc} Output var my_script; var style =...