Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:10:59+00:00 2026-05-24T17:10:59+00:00

I have created a bash script that should be started from a perl script.

  • 0

I have created a bash script that should be started from a perl script. When I run the bash directly from the terminal it works like a charm. But when trying to run the bash from my PERL-script I get a lot of permission errors.

Activities I do is creating files/directories/restaring apps/etc. How should I configure in order for the perl-script to be able to execute the bash without permission errors.

I execute the command from perl like this:

system($file, $arg);

Example of commands in bash:

exec 1>$1.log
exec 2>$1_error.log

mkdir /opt/$1

Example from error log for commands above:

[Wed Aug 10 18:17:17 2011] [error] [client 192.168.1.100] /opt/otrsadm/newinstance.sh: line 3: comp.log: Permission denied
[Wed Aug 10 18:17:17 2011] [error] [client 192.168.1.100] /opt/otrsadm/newinstance.sh: line 4: comp_error.log: Permission denied
[Wed Aug 10 18:17:17 2011] [error] [client 192.168.1.100] mkdir: 
[Wed Aug 10 18:17:17 2011] [error] [client 192.168.1.100] cannot create directory `/opt/comp'
[Wed Aug 10 18:17:17 2011] [error] [client 192.168.1.100] : Permission denied
[Wed Aug 10 18:17:17 2011] [error] [client 192.168.1.100]

What I am doing is creating a totally new instance of an application on an Apache. That means, the bash is creating necessary dir, copying the app to that dir, creating a new database and loading a template-dump, copying the application-specific config files for apache and exchanging some strings in that file, etc.

I am totally new doing this kind of activities so any possible help is highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:11:00+00:00Added an answer on May 24, 2026 at 5:11 pm

    You script is running under the same permissions as the Apache process. Good security practices require that your web server have as limited permissions as possible to change files that might themselves be run by the web server.

    Since this sounds like exactly what you want to do the trick is to loosen up the permissions as little as possible to get the result you want.

    My recommendation is to look into the program sudo. It can run programs as more privileged users, and provides some reasonable access controls. The basic idea would be to create a script that is owned, and only writable by the root user. Then allow the apache user (or httpd, or what ever your system calls the user running Apache) to execute that script through sudo as a user with the permission to write to /opt. If you can get away with executing the script as a user less privileged than root that is also good.

    Assuming you have good error checking in your script and follow all good security practices you will be reasonably secure.

    All that said, strongly consider paying an experienced, security minded developer to assist you with setting this up. Setting up a system like this requires a different mindset towords security, and that’s something you can’t get from an answer on SO. Otherwise you might have to explain to your boss how a 13 year old kid from some random country deleted all your companies data, or worse released it on BitTorrent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that I'm trying to run from cron. When I run
I have a bash script that I am run to check to see if
I have a bash script that checks some log files created by a cron
I have a Bash script that builds a string to run as a command
I have a bash script that creates a Subversion patch file for the current
I have created a PHP-script to update a web server that is live inside
I have created a few small flash widgets that stream .mp3 audio from an
I would like to have a script with an infinite loop, that kills all
I have created a simple bash script, chmod +x, and successfully am running it
I've created a small Bash script that does a MySQL data dump. Because the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.