Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I've got an IPCam that I can pull a still image from. Everything works honky dory there. What I want to do is to automatically call a script to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2006
    Posts
    1

    Newbie needs help with a bash script


    Hi
    I've got an IPCam that I can pull a still image from. Everything works honky dory there.
    What I want to do is to automatically call a script to capture a frame everytime someone accesses my homepage.
    I can get this to work, but my problem is that the script placed in my cgi-bin folder cannot write to the html folder where the script is called from.
    This is probably very basic, but I cannot understand why my simple script cannot write to html folder.
    It is obviously connected to permissions. It does work with cmod777 on the html folder, but I Don't want that. I've tried to add Apache to the group, but no go

    Here is my script:
    wget http://192.168.1.20:81/image.jpg --http-user=guest --http-passwd=
    cp image.jpg still.jpg
    rm image.jpg

    I call it like this SSI: <!--#exec cmd="bash /mypath/cgi-bin/myscript.pl" -->

    I get this errormessage
    --18:15:52-- http://192.168.1.20:81/image.jpg
    => `image.jpg'
    Connecting to 192.168.1.20:81... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 5,178 [image/jpeg]
    image.jpg: Permission denied

    Cannot write to `image.jpg' (Permission denied).
    cp: cannot stat `image.jpg': No such file or directory
    rm: cannot remove `image.jpg': No such file or directory


    Hope someone can help out a newbie, cause i'm getting really frustrated.
    -a-

  2. #2
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    you could just give the file access rights of 777, that should overrule the folder's write permissions... thus allowing full write access to that file, and not the rest of the directory.

    The other option is to chmod 755 the file, and then chown it to be the user that the script uses to write the file to the directory.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  3. #3
    Just Joined! krisguy's Avatar
    Join Date
    Feb 2006
    Posts
    7
    Quote Originally Posted by sdousley
    The other option is to chmod 755 the file, and then chown it to be the user that the script uses to write the file to the directory.
    That's what I would do. Then you have better security, plus you have an easier way to track issues in your logfiles.

Posting Permissions

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