Sponsored Content
Top Forums Shell Programming and Scripting how to run script? call other script? su to another user? make a cron? Post 302312954 by instant000 on Monday 4th of May 2009 08:54:53 AM
Old 05-04-2009
Java how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions:

1. How to write a script in HP-UX 11.

2. How to schedule a script. [using cron job.]

3. How to "call" scripts from the original script.

4. How to su to another user from within a script.

This is the basics of what the script should do.
su to a user
go to a specific directory
execute a process to stop a driver,
then another process to start a driver
exit su
begin the same as above, for the next user, and so on.


[I know the gist of the steps, because I do them from command line, but I
consulted with a person who works here, and he said you can't just script
the exits all in one file, because it'll make the script quit. My idea, is that
if we could somehow have the script call other scripts, that would work,
right? I hope that you gurus can assist lil 'ol me]

I need a script that does this:

1. call a second script, that does this:

2. su to user_x
3. cd to a specific directory
4. run a specific process to stop a driver [process already made, only
user_x can run it]
5. run a specific process to start a driver [process already made, only
user_x can run it]
6. exit [to quit out of su for user_x]

7. call a third script, that does this:

8. su to user_y
9. cd to a specific directory
10. run a specific process to stop a driver [process already made, only
user_y can run it]
11. run a specific process to start a driver [process already made, only
user_y can run it]
12. exit [to quit out of su for user_y]

13. call a fourth script, that does this: (you probably know where I'm
going with this by now ...)

14. su to user_z
15. cd to a specific directory
16. run a specific process to stop a driver [process already made, only
user_z can run it]
17. run a specific process to start a driver [process already made, only
user_z can run it]
18. exit [to quit out of su for user_z]

19. end of script

20. schedule script to run every morning at 5:30 AM using cron

I had looked around the forum, and I think I could do this so far:

script name: startdriver.sh

and it calls other scripts (something like this)

startdriver1.sh && startdriver2.sh && startdriver3.sh

I hope that someone can assist me. I don't know the syntax for writing
the scripts. I know the manual commands to type in during a session, but
not the scripting.

I know that we use HP-UX, and that we use cron for scheduling jobs.

I wish that I was more help.

If you need more information prior to assisting me, please give me a
command I can run to find out that information.

[I don't normally do Unix work. I want the script so that I don't have to
manually type in the commands.]

If this forum is not the proper place for a beginner such as myself, please
direct me to the proper forum.

Thanks!
 

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
script(1)							   User Commands							 script(1)

NAME
script - make record of a terminal session SYNOPSIS
script [-a] [filename] DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the record is saved in the file typescript. See WARNINGS. The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends when the forked shell exits or when Control-d is typed. OPTIONS
The following option is supported: -a Appends the session record to filename, rather than overwriting it. NOTES
script places everything that appears on the screen in filename, including prompts. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a privileged user, that is, root. Be sure that typescript is not a link before running script. SunOS 5.10 30 Jan 2004 script(1)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy