473,473 Members | 1,604 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how do i lock a ksh shell script

112 New Member
Hi,
I have a ksh shell script that accesses databases to drop and create tables and the script also creates text files.
This shell script is accessed thru a java application that i would like to turn multi-user, but the only way that i can do that is if I can figure out a way to lock the shell script so that only 1 user can access it at a time.
If 2 or more users access it, then bad things happen when 2 users and trying to drop and create the same database at the same time, or trying to create the same text file at the same time.

I would also like for the user to wait till the shell script is unlocked, instead of just passing over it or ending the application.

please help!!

thanks!!
Jul 7 '11 #1
1 2400
sicarie
4,677 Recognized Expert Moderator Specialist
I'm not sure how deep into the working of Linux you want to get, but you could just create a hidden file that is something like a system command (I think - a call that lets you run command-line commands inside a program) like 'touch .programname.lock', and have your script check to see if it exists or not before executing (and when it's done, remove the file through 'rm .programname.lock'. I know this functionality exists in Linux, however I don't know the calls to set it up through Java, but I'm sure a Google search would be able to help with that.

On the wait - how do you want your program to behave? Do you want it to keep trying (keep looking for the lock file) every 5/10/20 seconds? Or do you want to inform the user, and suggest they run the program again later?

I'd recommend coming up with the specific functionality you want - that will make it easier to code.
Jul 9 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: FPGA05 | last post by:
Hello All, I am developing a small application in which I would need a C++ application to read the output from a shell script. A shell script keeps looking for user inputs and once the user...
1
by: news | last post by:
At the end of a PHP script, I'm sending a file via FTP to a server. I thought it'd be best to use a shell script in order to automate the FTP (logging in, changing to binary, putting the file,...
0
by: Aashif | last post by:
I want to call Unix Shell script which is available in other Server (Unix server) from windows application using C#. Currently the shell script runs the C program but the GUI is not good, So I want...
9
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
3
by: telduivel | last post by:
Can someone please help me with this: I have a python script, that at some point calls a linux bash script (.sh). Starting the shell script is the last thing my python script needs to do, so I...
2
by: ellennolan | last post by:
Hello, I wonder if anyone can help with calling external shell script in c++. Basically, in the shellscript, I want to pass src, dst, md5. If the src's md5 matches md5 given, it will be link to...
2
by: smitanaik | last post by:
i have a java file which i am running through shell script. the syntax that i have used is #! /bin/bash javac Copy.java
5
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
4
by: devi thapa | last post by:
Hi, I am executing a python script in a shell script. The python script actually returns a value. So, can I get the return value in a shell script? If yes, then help me out. Regards, Devi
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.