LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-17-2013, 12:21 PM   #1
cparky2
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Rep: Reputation: Disabled
Validate User Command


Hi There

I have developed a virtual tutorial environment for Asterisk PBX. I would like the commands entered by users of this environment to be checked against a database of commands. Also i would like a simple application that would say success or fail depending on the outcome of a command. For instance, if the tutorial asked them to set chmod commands to 777 then it would say success if it had been applied properly. Any suggestions would be great.

Thanks
 
Old 03-18-2013, 10:10 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by cparky2 View Post
I would like the commands entered by users of this environment to be checked against a database of commands.
Well, what part of this are you having difficulty with? You can set up a database (or even just a list of strings in your program) and check if the command entered is in this list.

Quote:
Also i would like a simple application that would say success or fail depending on the outcome of a command. For instance, if the tutorial asked them to set chmod commands to 777 then it would say success if it had been applied properly.
Again, what part of this are you struggling with? For each task, you would have to define a list of criteria which check if the command has been executed correctly (e.g.
Code:
ls -l commands | grep "^-rwxrwxrwx" -q
for your example) and then get the program to execute each command in turn and check their return code: if they all return 0 for success, print "success", otherwise you can print an error message appropriate to which command failed.
 
Old 03-18-2013, 11:13 AM   #3
cparky2
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the response, much appreciated.

Well I would like it to display a percentage, for example of I asked for read/write privileges to be granted and the user only executed read privileges then It would say 50% or something similar. Is that possible? Would it be possible to write the application using C#?
 
Old 03-18-2013, 11:35 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
For the sort of detail you want, use the stat cmd to check the file/dir.
However, a percentage is meaningless in this context.
 
Old 03-19-2013, 05:58 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by cparky2 View Post
Thanks for the response, much appreciated.

Well I would like it to display a percentage, for example of I asked for read/write privileges to be granted and the user only executed read privileges then It would say 50% or something similar. Is that possible? Would it be possible to write the application using C#?
In both cases, yes - though I would probably attempt it in bash rather than C#.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Validate OpenVPN keys dazdaz Linux - Networking 1 11-20-2012 11:39 AM
[SOLVED] auth_mysql 3.0.0.0 w/ slackware 12.2 failing to validate user dhugh Slackware 4 09-01-2010 09:01 AM
Can someone validate this emclinux Programming 6 04-15-2009 09:32 PM
what is the command to make a user change their password after creating a new user? naweenio Linux - Newbie 7 01-05-2005 07:07 AM
Samba can't validate the users jen209110 Linux - Networking 1 01-12-2004 10:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:25 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration