Sponsored Content
Top Forums Shell Programming and Scripting how to run script? call other script? su to another user? make a cron? Post 302313141 by danmero on Tuesday 5th of May 2009 12:13:45 AM
Old 05-05-2009
Create a user.list file having the user.name , stop command and start command.
Code:
# cat <<eof>>user.list
user1 /path/to/user1/stop.proccess /path/to/user1/start.proccess
user2 /path/to/user2/stop.proccess /path/to/user2/start.proccess
eof

Use a loop to read from user.list and to test(echo) each command.
Code:
# while read user stop start
    do 
       echo su $user
       echo $stop
       echo $start
       echo exit
    done < user.list

The output will be:
Code:
su user1
/path/to/user1/stop.proccess
/path/to/user1/start.proccess
exit
su user2
/path/to/user2/stop.proccess
/path/to/user2/start.proccess
exit

When you have everything as you like , just remove the echo on your loop.

Success.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call shell script from php not run ?

Hi. I write a shell script for import data to oracle using sql loader. I set permission 755 or 777 for that script. I can run that script in the consol okay. When I call it from PHP using system command. I got return value 126 this value when don't have permission right ? I check step... (2 Replies)
Discussion started by: raccsdl
2 Replies

2. Shell Programming and Scripting

Can anyone make this script run faster?

One of our servers runs Solaris 8 and does not have "ls -lh" as a valid command. I wrote the following script to make the ls output easier to read and emulate "ls -lh" functionality. The script works, but it is slow when executed on a directory that contains a large number of files. Can anyone make... (10 Replies)
Discussion started by: shew01
10 Replies

3. UNIX for Dummies Questions & Answers

shell script run by user or cron job ?

My shell script runs fine both as a cron job and when i issue it. However, I wish to differentiate when it runs as a cron-job so the "echo" statements are not issued (they get mailed to me, which i don't want). I tried checking $USER but since the cron was created in my user that does not... (5 Replies)
Discussion started by: sentinel
5 Replies

4. Shell Programming and Scripting

howto run remotely call function from within script

Hi I have the following script : #!/bin/ksh #################### Function macAddressFinder ######################## macAddressFinder() { `ifconfig -a > ipInterfaces` `cat ipInterfaces` } ####################################################################### # # print... (2 Replies)
Discussion started by: presul
2 Replies

5. Shell Programming and Scripting

how we can make shell script not to run

Hi,shell script is scheduled from maestro and we want mastero should not run shell script so can we edit the shell script so that it should run.ThanksPrakash (5 Replies)
Discussion started by: prakashdba2010
5 Replies

6. Shell Programming and Scripting

help to make script run recursively

I have this little bash script I use to transcode mkv files using handbrake. #!/bin/bash sourcedir="/media/raid10/video/to_be_encoded_series" destdir="/media/raid10/video/series" cd "$sourcedir" for i in *.mkv; do HandBrakeCLI -i "$i" -o "$destdir/${i%.*}.mkv" -e x264 -q 20.0 -E copy -B... (4 Replies)
Discussion started by: barrydocks
4 Replies

7. Shell Programming and Scripting

Run script through cron with user environment variables

Hi everyone, I wrote a script that is supposed to be run by cron on a daily basis. It works just fine if I run it manually, but due to a lack of environment variables (which are available during my user session but not when cron runs the script) it keeps failing to run successfully. Here's the... (2 Replies)
Discussion started by: gacanepa
2 Replies

8. AIX

Commands to call script work from command line but not from Cron entry

My first post evidently did not materialize so I posted it again: Runnning a cron job every 5 mins to send data files to a state facility. My original cron entry at worked fine: 01,06,11,16,21,26,31,36,41,46,51,56 * * * * /home/sftpuser/stateinoc-from-appname.ksh Somewhere I have a... (1 Reply)
Discussion started by: Skyybugg
1 Replies

9. Shell Programming and Scripting

Bash script from makefile - it is called each time i call make

I've created a tag in the makefile: mytag: $(shell ${PWD}/script.sh) When i do: make clean - the script is executed When i perform make or make mytag the script is again executed with the output: make: Nothing to be done for mytag What i want ? I want script.sh to be executed only... (0 Replies)
Discussion started by: Pufo
0 Replies

10. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
LOCKS(3)						   libbash locks Library Manual 						  LOCKS(3)

NAME
locks -- libbash library that implements locking (directory based). This library is not throughoutly tested - use with caution! SYNOPSIS
dirInitLock <object> [<spin>] dirTryLock <object> dirLock <object> dirUnlock <object> dirDestroyLock <object> DESCRIPTION
General locks is a collection of functions that implement locking (mutex like) in bash scripting language. The whole idea is based on the fact that directory creation/removal is an atomic process. The creation of this library was inspired by studying CVS locks management. Same lock object can by used by several processes to serialize access to some shared resource. (Well, yeah, this what locks were invented for...) To actually do this, processes just need to access lock object by the same name. Functions list: dirInitLock Initialize a lock object for your proccess dirTryLock Try to lock the lock object - give up if its already locked dirLock Lock the lock object - will block until object is unlocked dirUnlock Unlock the lock object dirDestroyLock Destroy the lock object - free resources Detailed interface description follows. FUNCTIONS DESCRIPTIONS
dirInitLock <object> [<spin>] Initialize a lock object for your process. Only after a lock is initialized, your proccess will be able to use it. Notice: This action does not lock the object. The lock can be set on two types of objects. The first is an existing directory. In this case, Aq dir must be a path (relative or full). The path must contain a '/'. The second is an abstract object used as a lock. In this case, the name of the lock will not contain any '/'. This can be used to create locks without creating real directories for them. Notice: Do not call your lock object '.lock'. Parameters: <object> The name of the lock object (either existing directory or abstract name) <spin> The time (in seconds) that the funtion dirLock will wait between two runs of dirTryLock. This parameter is optional, and its value gen- erally should be less then 1. If ommited, a default value (0.01) is set. Return Value: One of the following: 0 The action finished successfully. 1 The action failed. You do not have permissions to preform it. 3 The directory path could not be resolved. Possibly parameter does contain '/', but refers to directory that does not exist. dirTryLock <object> Try to lock the lock object. The function always returns immediately. Parameters: <object> The object that the lock is set on. Return Value: One of the following: 0 The action finished successfully. 1 The action failed. The object is already locked. 2 The action failed. Your proccess did not initialize a lock for the object. 3 The directory path could not be resolved. dirLock <object> Lock given lock object. If the object is already locked - the function will block untill the object is unlocked. After each try (dirTry- Lock) the function will sleep for spin seconds (spin is defined using dirInitLock ). Parameters: <object> The directory that the lock is set on. Return Value: One of the following: 0 The action finished successfully. 2 The action failed. Your proccess did not initialize a lock for the directory. 3 The directory path could not be resolved. dirUnlock <dir> Unlock the lock object. Parameters: <object> The object that the lock is set on. Return Value: One of the following: 0 The action finished successfully. 2 The action failed. Your proccess did not initialize the lock. 3 The directory path could not be resolved. dirDestroyLock <object> Destroys the lock object. After this action the proccess will no longer be able to use the lock object. To use the object after this action is done, one must initialize the lock, using dirInitLock. Parameters: <object> The directory that the lock is set on. Return Value: One of the following: 0 The action finished successfully. 1 The action failed. The directory is locked by your own proccess. Unlock it first. 2 The action failed. Your proccess did not initialize the lock. 3 The directory path could not be resolved. EXAMPLES
Creating an abstract lock named mylock, with 0.1 second spintime: $ dirInitLock mylock 0.1 # $?=0 Locking it: $ dirLock mylock # $?=0 Trying once to lock it again: $ dirTryLock mylock # $?=1 Trying to lock it again: $ dirLock mylock # Will wait forever Unlocking: $ dirUnlock mylock # $?=0 Destroying the lock: $ dirDestroyLock mylock # $?=0 Trying to lock again: $ dirLock mylock # $?=2 Creating a lock on the directory ./mydir, with default spin time: $ dirInitLock ./mydir # $?=0 AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <gil@ran4.net> SEE ALSO
ldbash(1), libbash(1) Linux Epoch Linux
All times are GMT -4. The time now is 01:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy