how to run script? call other script? su to another user? make a cron?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to run script? call other script? su to another user? make a cron?
# 8  
Old 05-07-2009
Thanks for the assistance from both of you.

As I understand it, the "do while var1 var2 ..."
just assigns variables, while reading through a file, correct? And you can then substitute those variables later.

I saw another example [following your advice of researching more myself] where I see that I can specifically assign the variables.

So, it can be like "u=user1 w=stop1.script v=start1.script"

it was something with grouping, and you could assign all your variables in one line. Something like that. Obviously, I suspect that you understand this a lot better than I do.

Thanks. You've opened my eyes. I hope to begin testing today. Hopefully the admin isn't insecure about his job to not show me how he schedules the cron tasks! ... If I have issues with that, though, I'll try to read more FIRST, so my question will be a bit more knowledgeable, and show more effort on my part, instead of asking for a spoon fed, step-by-step answer.
# 9  
Old 05-07-2009
Try to spend some time here on unix.com and after few months get back to your first post/thread and think over Smilie
# 10  
Old 05-12-2009
Java

Good morning. I have tried further, but am still unsuccessful.

The echo works, but it does not execute as expected.

From what I have read on the hp.com forums, this problem could be related to the .profile of the users that I am calling to execute the commands.

http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1242136488365+28353475&threadId=38292

According to what I have read, this could be due to the fact that the user .profile is set up to load a certain user environment, but, I'm not understanding what they mean by changing this environment.

But, I did get the ttytype error that they are talking about "not a typewriter" or something to that effect during my experiments this morning.

I have attempted
su - usera -c commanda
su - userb -c commandb
su - userc -c commandc
what I get is that it appears to logon to each user's login environment (profile, as it were) but it only appears to actually run the command one time, at the very end.
At command prompt, I type it in this way (but of course, I would not be here, unless I wanted to script this.)
I tried a do loop, but it failed.

I tried concatenating scripts with an &, and they run, but I need the su portion, in order to have the permissions on the created file work, as the apparent usera, userb, userc need some perms on the files created as a result of running the script.
Example:
commanda& commandb & commandc
This works, but there is a file(s) created, and it is under "root" and I need the files created under usera, userb, userc, respectively. I saw something about chmod 4700 in the hp.com forums, but that made no sense to me, as I know of only three digits for chmod, so the fourth digit confuses me! What is the purpose of the 4700?

Once I had attempted this, the unix admin had to go back and delete the files wherever they were creted. (He was familiar with this problem, as he had dealt with it before.)

I also tried this:
creating three separate files
filea:
su - usera
commanda
exit
fileb:
su - userb
comamndb
exit
filec:
su - userc
commandc
exit

And concatenating them together on the command line:

filea & fileb & filec
and that didn't work, it appeared to log on to each user profile, and then only executed the commands for userc.

So, I'm back where I started, SOL.
# 11  
Old 05-12-2009
have you tried to put in a script for root containing:
Code:
su - <user1> -c "<your_users_script>"
su - <user2> -c <your_users_script>
su - <user3> -c <your_users_script>

Since it would be batch you would have to test in .profile for interactive shell..
su user just changes UID, you execute "as" user
su - user reads .profile and so loads user's environment (and this includes terminal keyb stuff cron doesnt like...)
you would use between doublequotes after -c if you are to enter more than a command (typically a script that accepts start or stop for argument)

Last edited by vbe; 05-12-2009 at 01:29 PM.. Reason: addendum
# 12  
Old 05-12-2009
OK here is what I modified in /etc/profile
look for the following line:
# Be sure that VUE does not invoke tty commands
and add after the first if so it looks like:
Code:
 Be sure that VUE does not invoke tty commands

 if [ ! "$VUE" ]; then
   if [[ $- = *i* ]]; then  #tty interactive test (VBE - 030306)
   # set term if it's not set
.
.

then look for the matching if and place before my if so it looks like:
Code:
   fi                                      #tty interactive test
 fi                                        # if !VUE

# Leave defaults in user environment

This wil avoid all the cron error messages such as " Not TTY .."
# 13  
Old 07-06-2009
Java Thanks for all of your help.

Thanks for all of your help. Our unix admin is leaving. I guess I'll deal with this in due time, I'm going to seek training first, though.
# 14  
Old 08-07-2009
Java Back to this thread, looking at the .profile of one of the users

I see nothing of the sort that you post in the .profile

This is what I see in the profile, as far as "terminal" setup. There is nothing else that I can find, with regards to "VUE" in the setup.
Code:
        # 
################################################################################
# @(#) $Revision: 72.2 $      
# Default user .profile file (/usr/bin/sh initialization).
# Set up the terminal:
 if [ "$TERM" = "" ]
 then
  eval ` tset -s -Q -m ':?hp' `
 else
  eval ` tset -s -Q `
 fi
 echo "Value of TERM has been set to \"$TERM\". "
 export TERM 
 stty erase "^H" kill "^U" intr "^C" eof "^D"
 stty hupcl ixon ixoff
 tabs
# Set up the search paths

I could post more, but it doesn't look necessary at this time. (If you say so, I will.)

thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question