Find the answer to your Linux question:
Results 1 to 6 of 6
Hey all I'm having one heck of an issue I hope you can help me with. I have a script if I login as "su" the script works like a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141

    permissions in scripts


    Hey all I'm having one heck of an issue I hope you can help me with.
    I have a script if I login as "su" the script works like a champ.
    BUT if I login as "su -" I get an error because the wrong fields are used.
    I know the easy answer..logiin as "su" but the db admins are used to"su -"
    and change here is like pulling teeth.
    I thougth it might be a permissions thing so I set the new scripts to 744 to match the old ..no help.
    What am I missing????????????

    thanks
    Mace

  2. #2
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    Ok I bit the bullet and changed the script to read the next field.
    Oh it worked BUT then when it tries to tar the file I get:

    tar: 10\:13: Cannot stat: No such file or directory

    BUT it puts a tar file in the directory under the correct name BUT not the correct byte count.
    Remember I had the above error last week

    So what the he!! am I missing what is messed up???????????????????

    thanks
    Mace

  3. #3
    Linux Enthusiast
    Join Date
    Jul 2005
    Location
    Maryland
    Posts
    522
    Quote Originally Posted by mace View Post
    when it tries to tar the file I get:

    tar: 10\:13: Cannot stat: No such file or directory
    I think the problem is that when you use:
    Code:
    su -
    it takes you to the user's ("root", if no other user specified) home directory,
    but when you use:
    Code:
    su
    it does not. So, it's just a matter of "where" you run the script (or where "tar" looks for files) .

    P.S. if you use "su" in the script, you may also have to use it with other options like -l -s and -c. See "man su" for that.

  4. #4
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    su - loads up a clean environment, like you would get if you logged in as that user to begin with. su doesn't have the clean environment, so any variables, aliases, and things like that will still be set from the original user. su - doesn't just change the home directory. Perhaps your script is relying on something that is not as easily accessible with a new, clean environment. It's very hard to tell what's going on without seeing the script itself.

  5. #5
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    Well I thought about it for awhile and came up with the fix.
    I deleted all the scripts and recreated them while I was root(su -)
    This solved the problem.
    Now the question is WHY?????????????
    thanks
    Mace

  6. #6
    jls
    jls is offline
    Just Joined!
    Join Date
    Apr 2007
    Posts
    13
    When you run the command 'su' a new, interactive shell is spawned belonging to user root. You remain in the same directory as when you ran the command. THat means your scripts and the files you are tarring are accessible with a relative path.
    When you run 'su -' you spawn a new login shell for user root. This means that a different initialisation file is read and also you will find yourself in /root which is roots home directory.

    Now if your script was relying on calling files that were in the directory from wich you issued the 'su -' command, and the absolute paths to these files were not specified in the script then you will get file not found errors.

Posting Permissions

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