|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Variable not an identifier when script is run as another user
I am new to scripting I keep getting the error var2= is not an identifier when I run this script as another user. BUT when I run it as myself, the script completes without error. Any idea why? I assume it is because the new user has a different environment . How do I make the variables active for this new user? I don't have setenv and I've already exported them. As I said, the script works fine until i run it after logging in and running su - newuser to change to the newuser. I wish I could fix this so the newuser could also run the script. Code:
echo "enter filername"
read filername
echo "enter days ago"
read daysago
command=`/px/finderquery -client=$filername -days=$daysago`;
export var2=`echo $command`;
if [[ `echo $var2 |grep show` ]];
then
echo "filer does not exist";
else
echo "you have the right name";
fi;
export new2=`echo $var2 |gawk '{print $31}'`Any ideas would be helpful to a newbie, thanks! Last edited by vbe; 11-29-2012 at 11:26 AM.. Reason: You insert your code in between the code tags! I revamped you code for reading... |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
What shell are you using?
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
I wonder if it is not a shell issue... Since in your code there is no shell, it will use your default, I suppose yours is a bash ( looking at your syntax...) it may not be true for your other user... otherwise it has to be something with your environment...
|
|
#4
|
|||
|
|||
|
duh... I should have told you I was using bash shell!
|
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
try puttinf as first line of your script: Code:
#!/bin/bash and see if it changes anything...( I suppose you made the script executable...) I cant do more, I dont use bash... |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
VBE: Dude, you are so right! The other user is running csh! Thanks for the help. I guess I will have to look into how csh treats variables. Maybe it uses setenv or something like that! Thanks for the help and if you have any further suggestions, let me know.
---------- Post updated at 01:41 PM ---------- Previous update was at 11:59 AM ---------- VBE you were right! using the #!/bin/bash fixed it! THANKS A MILLION! |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to allow a different user to run a script | DallasT | UNIX for Dummies Questions & Answers | 6 | 08-16-2011 08:36 AM |
| Run SAME SCRIPT as different user | linuxadmin | Shell Programming and Scripting | 2 | 07-16-2011 09:53 AM |
| Run the script as other user | vasuarjula | Shell Programming and Scripting | 5 | 01-19-2011 07:06 PM |
| Run script by another user | Mr.AIX | AIX | 2 | 10-03-2010 04:16 PM |
| Run the script from another user | Krishnaramjis | Shell Programming and Scripting | 4 | 11-02-2007 01:34 AM |
|
|