Find the answer to your Linux question:
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 ...
  1. #1
    Just 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

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    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.

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

  4. #4
    Just Joined!
    Join Date
    Jun 2006
    Posts
    40
    Quote Originally Posted by ynilesh View Post
    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.


    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

  5. #5
    Linux Newbie
    Join Date
    Feb 2008
    Location
    Bangalore, India
    Posts
    112
    Pawan,


    [pawan@gfmdatabase] $ ./retrive copybase
    ./retrive: line 7: [: =: unary operator expected
    Check If you are using correct syntax.

    ./retrive: line 24: ptime: command not found
    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 .

    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,
    Code:
     export PATH=$PATH:/home/pawan
    Make Sure 2 things,
    1. Your pawan user PATH is set to correct locations.
    2. Script has executable permissions.
    bigunix.blogspot.com
    Registered Linux User: #476440

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

  7. #7
    Linux 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).

    Code:
    ./retrive: line 7: [: =: unary operator expected
    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.

    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.

  8. #8
    Just Joined!
    Join Date
    Jun 2006
    Posts
    40
    Quote Originally Posted by i92guboj View Post
    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).

    Code:
    ./retrive: line 7: [: =: unary operator expected
    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.

    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.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...