Programming :: Single Instance Of Bash Script?
Sep 12, 2010
I have a bash script which is called automaticallyI want it so that if when the script is called if a previous instance of it is already running then to delay the running of it until the previous instance has stopped (effectively queue up ./script.sh var1 var2)I have seen some posts about a 'lockfile' but this just seems to stop the second instance running rather than queueing it up to run next (it also needs to be able to queue up a 3rd/4th calling of the script and run them one at a time)
View 14 Replies
ADVERTISEMENT
Jul 21, 2010
There is probably a very simple fix, but its wrecking my buzzI call the following on the command lineR CMD BATCH '--args Y_filename="one.txt" out="two.txt"' brew.RI want to call this from a bash script but replace one.txt with $1, and two.txt with $2 (ie the first two arguments from the command line)I have tried in vane"R CMD BATCH '--args Y_filename="$1" out="$2"' brew.R"
View 8 Replies
View Related
Jul 22, 2010
AKA "zipping on the fly .. the slow-as-molasses way." The list includes full pathnames to each file, and they're all in subfolders of the same parent folder (which, unfortunately, is not the root folder of the drive or system on which the files reside). A cleaned-up and radio-ready portion of the list looks like
Quote:
.../taiga/ahqr-va-choyvp/bv0884-073.jpg
.../taiga/ahqr-va-choyvp/bv2635-073.jpg
.../taiga/ahqr-va-choyvp/bv3067-175.jpg
[code]....
What I'd like to be able to do is zip all the files in the list into a single archive, to avoid the step of having to copy them to the same location (presumably another folder on the HD) and then zip that folder. I'm more inclined to make provisions about extracting to a single folder at some other time. Is this possible in BASH, or would I have to consider a faster, more robust scripting language such as python or perl?
View 8 Replies
View Related
Aug 18, 2010
Possible Duplicate: Can history files be unified in bash? I have bash running in an ssh session, call this session A. I leave the office, go home, ssh to the same box, call this session B. From session B, I'd like to be able to look at the history of session A.
View 1 Replies
View Related
Mar 10, 2011
I have something like...
Code:
var=beer
# echo ${var/%e/E} doesn't do anything because i can only replace "r" or "er" this way
[code]....
View 1 Replies
View Related
Nov 23, 2010
I am starting an instance of mplayer from a bash script, opening an audio stream:
Code:
mplayer [URL]
How do I do to control this mplayer instance from another script? I want to control volume and pause it from within the bash script. I know the commands for doing so from terminal, but once mplayer gets started from the script, how do I 'direct' the commands to that specific mplayer instance?
View 9 Replies
View Related
Oct 13, 2010
I have question about the UNIX sockets. my goal is to connect multiple sockets from a single client to a single server and keep them open...I'm not sure if that is possible to create or not. Do you have any suggestion or an example of code?
View 1 Replies
View Related
Apr 27, 2010
I can define all variables in tcl programming in a file for instance var.cfgand source the same file in my tcl script such assource var.cfgIs this possible in perl too?
View 3 Replies
View Related
Feb 15, 2010
I have KDE 4.4 and Firefox 3.6. Whenever I click a link from a plasmoid widget, it tries to open Konqueror and another instance of Firefox. The page actually loads in the opened Firefox window, but the task bar shows an instance of Konqueror and another instance of Firefox, that keeps loading for a while then close. See image below:
I currently have setup the browser default application as "firefox". If I set this option to use the default application, it opens in Konqueror and I don't see additional windows in the task bar. If I change the option to "firefox %u", then it exhibit the same issue, but the process is much faster, so the loading windows don't stay for long in the task bar. Additionally, it opens the link on a new Firefox window and opens the page twice. Although Konqueror is not loaded, the bouncing icon next to the mouse pointer shows up and stay for a while.
View 1 Replies
View Related
Apr 6, 2011
I have two classes, for argument's sake A and B. A implements the core functionality, B is an encapsulated data structure. If you imagine this situation
[code]...
From within B's member functions, I would like to access the public function() in class A. This is not an inheritance issue, they are two discrete classes with radically different functionality. Class A makes an object of B.
View 5 Replies
View Related
Dec 11, 2010
I need to write a shell script that will be run from cron every minute or so. The script will use rsync to keep some folders across several machines in sync. I am very new to shell scripting so some answers might seem obvious but they are not to me:
1. How do I check at the beginning of the script if the script is already running and abort if it is? I saw that most processes use a PID file for that but I am not sure this is the right case for that and in fact how to do it exactly
2. Assuming the list of target machines/dirs to sync are supposed to come from some config file. How should I code that? Just use the normal shell tools that I already know (cut etc) or is there a better way?
View 6 Replies
View Related
Apr 6, 2011
The intent here takes a little background info.I'm trying to make a basic inventory control to reinforce my studies. It will have a while loop that displays amenu for add, edit, view, and quit. Lets assume the following:
Code:
class inventoryItem:
itsDescriptiveName = None
[code]....
View 5 Replies
View Related
Jul 13, 2010
I have written a code in which i have used vectors:
vector< vector<double> > arr;
arr.resize(x,vector<double>(x,0));
x is a variable which is taken from a very beg text file > 64MB
first line of my code is
cout<<"
Wait Running...";
my code takes text file as an input, takes its data and generates an output text file....
Code is running fine for small data tried till x= 10
but while trying to run with large data ie x = 5000000 approx it is giving error
Even the first line of the code is not displayed. NOTE: variable is declared global but its size is defined in main.
The error that i am getting after approx 2-3 minutes is:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Wait Running...Aborted (core dumped)
View 6 Replies
View Related
Nov 1, 2010
This is more of a bash or scripting How do you update a single line of an output in a bash script. I have had to do the:
[Code]..
Is there a way to clear only a single line of output? my goal is to mimic a single line animation, much like the '=>' '==>' ' ===>' we have all seen in other programs.
View 3 Replies
View Related
Sep 28, 2010
A simple TCP based chat server could allow users to use any TCP client (telnet, for example) to communicate with each other. For this question you should consider a single process, single thread server that can support exactly 2 clients at once, the server simply forwards whatever is sent from one client to the other (in both directions). Your server must not insist on any specific ordering of messages as soon as something is sent from one client it is immediately forwarded to the other client. As soon as either client terminates the connection the server can exit
View 4 Replies
View Related
Jul 11, 2011
I've written a script (that doesn't work) that looks something like this:
#!/bin/sh
screen -dmS "somename" somecommand
for i in {0..5}; do
screen -dmS "name$i" anothercommand $i
done
For some reason, if I copy and paste this into a terminal, it creates 7 detached screen sessions as I expect. If I run it from within a script, however, I get only the first session, "somename," when I run screen -ls.
Edit: If the same can be accomplished another way (e.g. with multiple screen windows instead of sessions), I would be open those solutions as well.
View 3 Replies
View Related
Sep 28, 2010
i want a process that can operate as both a TCP echo server and a UDP echo server. The process can provide service to many clients at the same time, but involves a single process that does not start up any other threads.
View 3 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Jan 24, 2010
simple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
View 10 Replies
View Related
Nov 26, 2008
I have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
View 3 Replies
View Related
Jul 25, 2011
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
View 5 Replies
View Related
Jan 9, 2010
I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:
Let FILE="thefilenameofsomefilesfor_instance.txt"
Code:
NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`
I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.
View 5 Replies
View Related
Apr 26, 2010
Would like to know how to cat the below output.
Code:
grep userlist_file /etc/vsftpd/vsftpd.conf | cut -c15-
Below which is the output for above command.
[code]...
View 6 Replies
View Related
Mar 14, 2011
I would like to create a bash script that creates a single group from all users in other groups.
I've been at it most of the day, and I think I'm making it too complicated. I have about 100 lines of code, and it's still now working the way I would like. I'm starting to trip over my own feet with the amount of if statements and variables.
View 1 Replies
View Related
Apr 21, 2010
Running Ubuntu and writing simple C programs. I need 2 text windows, the one I have started in, and a second to display some debug information. I can start a second screen using popen("/usr/X11R6/bin/xterm" "w"), and I get my new text window. However, it is running a shell and I can't send any info to it!
View 4 Replies
View Related
Jan 21, 2010
I want to convert double quote to single quote in a text file. I tried escape characters however no success. Please find details as follows:
-sh-3.00$ sed 's/"/'/g test.txt
sed: -e expression #1, char 7: unterminated `s' command
-sh-3.00$ cat test.txt
"unix"
I want "unix" to be converted to 'unix'
View 7 Replies
View Related
Oct 30, 2010
I am working on an structure program and i have to represent a 2,4 tree in a class in Java using single int array and make the insert and delete functions .
View 1 Replies
View Related
Mar 31, 2011
I need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
View 10 Replies
View Related
Dec 30, 2010
I have a text file called namelist.wps. In this file there is a line that reads:Code: start_date = '2010-12-26_12:00:00', '2010-12-26_12:00:00', I have to automatically update the year, month, and day of month. I set values for the year, month, and day of month using the following code in a c-shell script:Code: set y1 = `date +%Y`set m1 = `date +%m`set d1 = `date +%d` After I do this, how do I update year, month, and day of month, without changing any of the other lines in the namelist.wps file?
View 2 Replies
View Related
Mar 18, 2011
I have apache ,jboss and jon instances on various linux boxes.I need to create a generic startup script to restart those instances on server reboot.The script requirement is :It should take the name of instances from one text file named active-servers and recycle those instances.1. start-mws-servers (generic script for /etc/rc.d but just create it in ~/bin dir for current testing)It simply searches ~/bin/active-servers for active server recycle scriptsIt executes each recycle script and passes it the 'start' commandIt logs results to /tmp/start-mws-servers.
View 1 Replies
View Related