Results 1 to 8 of 8
Hi,
I've 2 users accessing a system with their own username/passwd.
A simple script is located on that system at:
/E*user/home/adm/manual/retrive.pl
Both users are accessing the same script after logging ...
- 07-31-2008 #1Just Joined!
- Join Date
- Jun 2006
- Posts
- 40
Simple script giving syntax error
Hi,
I've 2 users accessing a system with their own username/passwd.
A simple script is located on that system at:
/E*user/home/adm/manual/retrive.pl
Both users are accessing the same script after logging into same system. But, with 1st user the script is runnnig just fine, while with 2nd user giving out a syntax error on attempt to run it.
Is this related to access permissions or something related to user's profile issue ????
Please adivce, that I can check to find the reason behind this issue.....anything I can check like $SHELL, .profile of both the users..???
Thanks
Pawan Sangal
- 07-31-2008 #2
I'm guessing that if you remove the asterisk ("*") from the "E*user" in the actual path, you'll have better luck.
That is, rename the directory, and then modify your script accordingly. You'll also have to modify everything else that refers to this directory.
Using an asterisk in a directory or file name is a really bad idea, because when you use a shell command to refer to that directory, or to a path which includes that directory, wild carding comes into play.
Another character to avoid is the question mark ("?").
Fix this on general principle. If you're still having problems, please post the exact, complete error message.--
Bill
Old age and treachery will overcome youth and skill.
- 07-31-2008 #3Linux Newbie
- Join Date
- Feb 2008
- Location
- Bangalore, India
- Posts
- 112
If you dont want to run script at a time by both users, you can put a lock when 1 user is running script and remove lock once he is done. then let other user again run script
.
Agree with wje_lf please paste exact error message.bigunix.blogspot.com
Registered Linux User: #476440
- 08-01-2008 #4Just Joined!
- Join Date
- Jun 2006
- Posts
- 40
Thanks Bill and Nilesh....for your prompt reply...
Actaully, its a simple shell script, which is working fine with 1st user "arun" and giving below syntax error with 2nd user "pawan". However, both the users are accessing the same box, same directory and same script.
Here's the exact error, while executing the script with Pawan's profile:
[pawan@gfmdatabase] $ cd /E\*user/home/adm/manual
(2) /E*user/home/adm/manual
[pawan@gfmdatabase] $ ./retrive copybase
./retrive: line 7: [: =: unary operator expected
PROLOGINITSIZE previously set to 200M
You are using: ptime
PROLOGINITSIZE is 200M
./retrive: line 24: ptime: command not found
(2) /E*user/home/adm/manual
[pawan@gfmdatabase] $
Same script is running just fine with user "arun".
Kindly suggest, as I think its something related to either the profile settings issue with user's profile like shell/environment variables.
If yes, then can you please suggest me what things should I look for, to get a perfect solution in this case ?
Thanks
Pawan Sangal
- 08-01-2008 #5Linux Newbie
- Join Date
- Feb 2008
- Location
- Bangalore, India
- Posts
- 112
Pawan,
Check If you are using correct syntax.[pawan@gfmdatabase] $ ./retrive copybase
./retrive: line 7: [: =: unary operator expected
It seems ptime is customized command which you are using in your script. But your program not able to find it in standard bin locations like /usr/bin, /usr/sbin, /usr/local/bin etc ../retrive: line 24: ptime: command not found
solutions,
1. Create a symlink to ptime in /usr/bin so when script runs it will get it from standard bin locations.
2. You can export the location of ptime command at the beginning of the script. ex. assume ptime command is there in your home directory then command will be,
Make Sure 2 things,Code:export PATH=$PATH:/home/pawan
1. Your pawan user PATH is set to correct locations.
2. Script has executable permissions.bigunix.blogspot.com
Registered Linux User: #476440
- 08-01-2008 #6Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Yes, I'm sure it is a really good idea not to show us the code that is causing the problems. We might actually be able to see the error then. It is much more effective for us to make wild guesses.
That having been said (although it probably should have been said entirely in BOLD), this
/retrive: line 7: [: =: unary operator expected
indicates that you are using something like
if [ $var = 42 ]
and that $var is actually "" in this case.
- 08-01-2008 #7Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Obviously:
1.- environment for both users is different, that includes the path (hint 1)
2.- one argument, env var or something is defined for one user, and not another (hint2, and related to this error).
This line might contain a var that has different values for the users (in fact, I suspect that one var is defined for one and empty for the other as the user above also said). I know, too general and nothing concrete... As the user above said, we can only guess since you did not show the code.Code:./retrive: line 7: [: =: unary operator expected
I doubt you are going to get any more concrete response since in first place we don't know which is what needs to get fixed (so we can't fix it).
Please, if you need additional support, post the code.
Cheers.
- 08-05-2008 #8Just Joined!
- Join Date
- Jun 2006
- Posts
- 40
Hi All,
My sincere thanks to everybody who contributed and suggested me some very good hints, that really helped me to resolve the problem.
Yes, I found the reason behind the script failure (giving syntax error) with 2nd user, which is running totally fine with 1st user.
As, I said above, one thing is clear into my mind that the script is OK...since its the same script both users are running and creating problem only with the 2nd user. So, I didn't bothered with the script much.
But, yes someone suggested me to put the code of the script. I've to provide that also, but not until I feel totally helpless from my side. I again went around the script and checked the errored response. There, I found a variable being used within the script. But, was not defined any where in that script.
Then I checked the environment variables as the variable value may be present in the environment of 1st user and may not with 2nd user's case.
And, thats it.....
I found that a variable is being exported with 1st user's profile which is further used by that script, and the same was not in the environment of 2nd user's case.
I simply, provided the expected value for that variable in the 2nd user's ".bash_profile" and just exported that by executing the .bash_profile from the same location.
I checked: (for both users)
env
.bash_profile
Now, the problem is no where....and I was the happiest person to send an email to that 2nd user, that please retry the script from her profile now.
My experience here, is that something that is hitting my mind helped....and a lot from the suggestions provided by experts regarding the script code and environment variables review.
Thanks a lot...!!!!


Reply With Quote
