LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-08-2014, 10:13 AM   #1
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,320

Rep: Reputation: 36
Give users access to run a script saved on server


right now i have a cron'd shell script which does some things and also calls a perl script. Every once in a while we need to run it manually, but right now only IT folks who can log into the server can run it.

Can anyone think of a creative way that would let regular users from their PCs be able to run the shell script, without giving them a logon to the server itself or any permissions (so no webmin access to go to scheduled jobs).
 
Old 01-08-2014, 10:39 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 13,778

Rep: Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349Reputation: 2349
Quote:
Originally Posted by rjo98 View Post
right now i have a cron'd shell script which does some things and also calls a perl script. Every once in a while we need to run it manually, but right now only IT folks who can log into the server can run it.

Can anyone think of a creative way that would let regular users from their PCs be able to run the shell script, without giving them a logon to the server itself or any permissions (so no webmin access to go to scheduled jobs).
Well, a simple PHP web page with one button on it would do the trick. Running an external script is fairly trivial for PHP, and you could put a simple user ID/password on it with just a .htaccess to keep it simple, if you wanted to 'secure' it a bit. Heck, since it's a perl script, you could just link it to your cgi-bin directory, and run it as-is (possibly).
 
1 members found this post helpful.
Old 01-08-2014, 11:47 AM   #3
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,320

Original Poster
Rep: Reputation: 36
OK. I'll have to see if I can find a sample online of a php webpage that would do that, I don't know php myself. glad it's something fairly simple though like that. I think there is an instance of lampp running on the server that contains the scripts, so I guess that could host the page too, assuming I can figure it out haha.
 
Old 01-08-2014, 11:55 AM   #4
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 2,721
Blog Entries: 3

Rep: Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626
PHP Code:
<?php
$output 
shell_exec(/path/to/perl /path/to/script.pl);
echo 
"$output" ;
?>
Save as userscript.php and run with http://server.com/userscript.php
Give it the correct owner:perms as with any php file in DocumentRoot...

Should work.

Enjoy.
 
3 members found this post helpful.
Old 01-08-2014, 11:58 AM   #5
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,320

Original Poster
Rep: Reputation: 36
wow, thanks! Now it's actually a .sh that as part of it calls a .pl, if that makes a difference?
 
Old 01-08-2014, 12:05 PM   #6
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 2,721
Blog Entries: 3

Rep: Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626
You're very welcome.
unless the enviroment "needs" some variables, I'd use just the perl part of it at first.
This suggests you can run a shell script in php.

Good Luck!

Edit:
Can you show us the shell script? (sanitize if necessary)

Last edited by Habitual; 01-08-2014 at 12:07 PM.
 
Old 01-08-2014, 12:14 PM   #7
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,320

Original Poster
Rep: Reputation: 36
OK, I will give it a shot and just put my .sh file name in where you had the .pl in your example

Here's the sanitized .sh file:

Code:
#!/bin/bash
/usr/bin/wget --user=username --password=password 'http://page.com' -O /dir/ect/ory/file.htm
/usr/bin/perl /dir/ect/ory/my_ftp_script.pl

echo done.
then the pl file just connects to the ftp site and does a put of file.htm
 
Old 01-08-2014, 12:19 PM   #8
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 2,721
Blog Entries: 3

Rep: Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626
Quote:
Originally Posted by rjo98 View Post
then the pl file just connects to the ftp site and does a put of file.htm
a put or a pull?

Unless /usr/bin/perl /dir/ect/ory/my_ftp_script.pl
does some processing based on the file.htm, then it may not be necessary to include it.

Keep us updated on your progress!
 
Old 01-08-2014, 12:24 PM   #9
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,320

Original Poster
Rep: Reputation: 36
my .sh file grabs a webpage we create then creates this file.htm file I need to send somewhere else, then the .pl does the actual 'put' onto the ftp server where file.htm needs to go.
 
Old 01-08-2014, 12:42 PM   #10
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 2,721
Blog Entries: 3

Rep: Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626
Well, I'd try the entire .sh script.
What's the worse that can happen?

Errr, make that "couldn't hurt"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i give root access to multiple users? bakekelwa Linux - Newbie 14 07-19-2007 11:14 AM
how to give access to KPPP to users other then root mystic_durle12 Linux - Newbie 5 06-30-2007 05:33 PM
give access to users Hern_28 Slackware 2 03-21-2007 02:29 PM
Give certain users more access to resources tearinox Slackware 2 05-21-2004 02:44 AM
give users access to home dirs jonas73 Linux - Newbie 2 03-16-2004 01:42 AM


All times are GMT -5. The time now is 10:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration