Sponsored Content
Top Forums Programming Creating a bash based restricted shell Post 302849781 by Skrynesaver on Tuesday 3rd of September 2013 10:39:14 AM
Old 09-03-2013
bash uses the readline library to implement the auto complete, line up, emacs keys editing in commands.

There is a Perl "scriptable" equivalent, Term::Readline which may provide a suitable easily programmable shell for you
This User Gave Thanks to Skrynesaver For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating email based on an output

Hello folks. I need to create a script that looks at a certain output (list of full paths of files) and gets the owner's name (2nd position in the path, for example: /dirA/jsmith/blah1/more_blah/still_blah... etc) Gets the jsmith and greps the related file for jsmith and send that output to... (1 Reply)
Discussion started by: saswerks
1 Replies

2. Shell Programming and Scripting

shell: creating different arrays based on function argument

hi, I was wondering if there was a good way to create an array within a function, where the name is based on a passed argument? I tried this: _____________________________ func(){ #take in 1st arg as the arrayname arrayName=$1 let i=0 while read line do arrayName=${line} let i+=1... (5 Replies)
Discussion started by: nix21
5 Replies

3. UNIX for Advanced & Expert Users

Creating USERs with restricted Access

Hi There, i need to creat USERS in UNIX with restricted access to different directories. for example user1 should have access to dir1 and dir2 user2 should have access to dir2 and dir3 Please help me (4 Replies)
Discussion started by: ramanan25
4 Replies

4. Shell Programming and Scripting

Bash shell: Creating Preferences

In OS X I'm currently writing a bash script that requires writing to preference file. I may eventually want to share it with users on other Unix-like OSs and would like to accommodate for that possibility ahead of time. Most OS X applications save preferences in xml-format plist files. These... (4 Replies)
Discussion started by: airsmurf
4 Replies

5. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

6. Shell Programming and Scripting

Creating a command on a BASH shell

Hi all. Suppose I have the following function in an executable file named "HOLA": ------------------------ function hola { echo "Hola ${@}."; } ------------------------ In addition, suppose that I want to execute the file so I can input my name next to ./HOLA. I mean,... (4 Replies)
Discussion started by: hresquivelo
4 Replies

7. AIX

Restricted shell

Hello I have a user with a Restricted Shell on a Aix 5.3. My question is about if I can add one more path on the home directory. I mean the user have in his home directory. for example /test/my_application/logs but I need that this user can view another log that is on another path, if this... (1 Reply)
Discussion started by: lo-lp-kl
1 Replies

8. UNIX Desktop Questions & Answers

Restricted shell with execution permission on a file

Hi, I've created a user which shell is the restricted one (/usr/lib/rsh), but I've realized that the user cannot execute a script !!! The scope was to allow the ssh access to a user that could not access to any other directories but there that user should be able to run a script that retrieves ... (2 Replies)
Discussion started by: mary0
2 Replies

9. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

10. Shell Programming and Scripting

Creating a text based game using shell script.

Hello guys I'm new to shell scripting and I need to make a game using shell script. I want to know if it is possible for me a total noob to shell scripting to make this game. The game concept is simple: First thing when you launch the script you get a menu in which you select if you want to... (3 Replies)
Discussion started by: Othmane
3 Replies
Term::ReadLine(3pm)					 Perl Programmers Reference Guide				       Term::ReadLine(3pm)

NAME
Term::ReadLine - Perl interface to various "readline" packages. If no real package is found, substitutes stubs instead of basic functions. SYNOPSIS
use Term::ReadLine; my $term = Term::ReadLine->new('Simple Perl calc'); my $prompt = "Enter your arithmetic expression: "; my $OUT = $term->OUT || *STDOUT; while ( defined ($_ = $term->readline($prompt)) ) { my $res = eval($_); warn $@ if $@; print $OUT $res, " " unless $@; $term->addhistory($_) if /S/; } DESCRIPTION
This package is just a front end to some other packages. It's a stub to set up a common interface to the various ReadLine implementations found on CPAN (under the "Term::ReadLine::*" namespace). Minimal set of supported functions All the supported functions should be called as methods, i.e., either as $term = Term::ReadLine->new('name'); or as $term->addhistory('row'); where $term is a return value of Term::ReadLine->new(). "ReadLine" returns the actual package that executes the commands. Among possible values are "Term::ReadLine::Gnu", "Term::ReadLine::Perl", "Term::ReadLine::Stub". "new" returns the handle for subsequent calls to following functions. Argument is the name of the application. Optionally can be followed by two arguments for "IN" and "OUT" filehandles. These arguments should be globs. "readline" gets an input line, possibly with actual "readline" support. Trailing newline is removed. Returns "undef" on "EOF". "addhistory" adds the line to the history of input, from where it can be used if the actual "readline" is present. "IN", "OUT" return the filehandles for input and output or "undef" if "readline" input and output cannot be used for Perl. "MinLine" If argument is specified, it is an advice on minimal size of line to be included into history. "undef" means do not include anything into history. Returns the old value. "findConsole" returns an array with two strings that give most appropriate names for files for input and output using conventions "<$in", ">out". Attribs returns a reference to a hash which describes internal configuration of the package. Names of keys in this hash conform to standard conventions with the leading "rl_" stripped. "Features" Returns a reference to a hash with keys being features present in current implementation. Several optional features are used in the minimal interface: "appname" should be present if the first argument to "new" is recognized, and "minline" should be present if "MinLine" method is not dummy. "autohistory" should be present if lines are put into history automatically (maybe subject to "MinLine"), and "addhistory" if "addhistory" method is not dummy. If "Features" method reports a feature "attribs" as present, the method "Attribs" is not dummy. Additional supported functions Actually "Term::ReadLine" can use some other package, that will support a richer set of commands. All these commands are callable via method interface and have names which conform to standard conventions with the leading "rl_" stripped. The stub package included with the perl distribution allows some additional methods: "tkRunning" makes Tk event loop run when waiting for user input (i.e., during "readline" method). "event_loop" Registers call-backs to wait for user input (i.e., during "readline" method). This supersedes tkRunning. The first call-back registered is the call back for waiting. It is expected that the callback will call the current event loop until there is something waiting to get on the input filehandle. The parameter passed in is the return value of the second call back. The second call-back registered is the call back for registration. The input filehandle (often STDIN, but not necessarily) will be passed in. For example, with AnyEvent: $term->event_loop(sub { my $data = shift; $data->[1] = AE::cv(); $data->[1]->recv(); }, sub { my $fh = shift; my $data = []; $data->[0] = AE::io($fh, 0, sub { $data->[1]->send() }); $data; }); The second call-back is optional if the call back is registered prior to the call to $term->readline. Deregistration is done in this case by calling event_loop with "undef" as its parameter: $term->event_loop(undef); This will cause the data array ref to be removed, allowing normal garbage collection to clean it up. With AnyEvent, that will cause $data->[0] to be cleaned up, and AnyEvent will automatically cancel the watcher at that time. If another loop requires more than that to clean up a file watcher, that will be up to the caller to handle. "ornaments" makes the command line stand out by using termcap data. The argument to "ornaments" should be 0, 1, or a string of a form "aa,bb,cc,dd". Four components of this string should be names of terminal capacities, first two will be issued to make the prompt standout, last two to make the input line standout. "newTTY" takes two arguments which are input filehandle and output filehandle. Switches to use these filehandles. One can check whether the currently loaded ReadLine package supports these methods by checking for corresponding "Features". EXPORTS
None ENVIRONMENT
The environment variable "PERL_RL" governs which ReadLine clone is loaded. If the value is false, a dummy interface is used. If the value is true, it should be tail of the name of the package to use, such as "Perl" or "Gnu". As a special case, if the value of this variable is space-separated, the tail might be used to disable the ornaments by setting the tail to be "o=0" or "ornaments=0". The head should be as described above, say If the variable is not set, or if the head of space-separated list is empty, the best available package is loaded. export "PERL_RL=Perl o=0" # Use Perl ReadLine sans ornaments export "PERL_RL= o=0" # Use best available ReadLine sans ornaments (Note that processing of "PERL_RL" for ornaments is in the discretion of the particular used "Term::ReadLine::*" package). perl v5.18.2 2014-01-06 Term::ReadLine(3pm)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy