simulate linux shell using script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simulate linux shell using script
# 1  
Old 09-10-2010
simulate linux shell using script

hi guys

I was requested to create a script to simulate a linux shell so when the user opens linux he will get my linux menu with some options and one of those is a simulated linux shell

this is my code

Code:
#!/bin/ksh
while [ "$whichcmd" != end ]
     do
     read whichcmd?"Enter Command: "
     $whichcmd
     done
     whichcmd=0

but commands like these ones won't work

Code:
/sbin/ifconfig -a | less
/sbin/ifconfig > ip

it looks like when using | or > or similar characters my simulated command line won't work

any idea how to improve this simulated command line?

thanks a lot
# 2  
Old 09-10-2010
Try it with eval, the script should be like:
Code:
#!/bin/sh

while true
do
  read -p "Enter Command: " whichcmd
  if [ "$whichcmd" = "end" ]
  then
    exit
  fi
  eval "$whichcmd"
done

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 09-10-2010
Code:
#!/bin/ksh
while [ "$whichcmd" != end ]
     do
     read whichcmd?"Enter Command: "
     eval $whichcmd
     done
     whichcmd=0

# 4  
Old 09-10-2010
Note that eval isn't really limited, so if this is supposed to be any sort of secure or restricted shell, not a good idea. Not too hard to devise a way to do anything up to the limits of the login's permissions.
# 5  
Old 09-10-2010
I hate to ask this question, but what is the purpose of the simulated Linux shell? What does it accomplish if you are going to allow a user to type any command and the simulated shell then executes that command?
# 6  
Old 09-10-2010
Quote:
Originally Posted by fpmurphy
I hate to ask this question, but what is the purpose of the simulated Linux shell? What does it accomplish if you are going to allow a user to type any command and the simulated shell then executes that command?
my customer is trying to follow the PCI compliance on their linux servers so they asked to do that.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wget script to simulate real user visits

so i'm using the following script to attempt to simulate a user visiting a page but unfortunately, it doesn't look like this is working: wget -nv -r "http://www.mywebsite.com" does anyone have a better idea of how to do this? the goal here is to run a wget command from a linux host to a... (3 Replies)
Discussion started by: SkySmart
3 Replies

2. Shell Programming and Scripting

How to simulate ''Esc'' keystroke in a bash shel script?

I am using Ubuntu 12.4 I am running the following script: ++++++++ #!/bin/bash while ; do xdotool mousemove 248 539 click 1 & sleep 3 done +++++++++ This moves the mouse on the specified position on the screen and clicks that pauses the script for 3 seconds and repeats the... (2 Replies)
Discussion started by: alfarnume
2 Replies

3. Shell Programming and Scripting

Script Shell Linux

Hello, Please, how can I complete this script: Thank you (2 Replies)
Discussion started by: chercheur857
2 Replies

4. Shell Programming and Scripting

How Do I Simulate a Shell Terminal via PHP?

----------- Summary ----------- I need a command/set of commands that can help me simulate a shell terminal via a PHP web page using commandline functions. How can I combine the power of nohup and a while loop to: start the shell, execute commands and print output (and errors i.e. 2>&1)... (8 Replies)
Discussion started by: blogmaster
8 Replies

5. Programming

Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX

Writing a Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX I have over the years come across the same issue a couple of times, and it normally is that the read speed on SAN is absolutely atrocious when doing non-sequential I/O to the disks. Problem being of... (7 Replies)
Discussion started by: vrghost
7 Replies

6. Programming

Does anybody know how to simulate press Fn+Scroll Lk in Linux c

Does anybody know how to simulate press Fn+Scroll Lk in Linux c? Thanks in advance! (10 Replies)
Discussion started by: liuyan03
10 Replies

7. Shell Programming and Scripting

simulate session.getMaxInactiveInterval() in bash script

hi everyone, I have a question about the java object oriented function which to simulate in bash script... here is the function "session.getMaxInactiveInterval() / 60 " got any web can read this function? coz i need to simulate to bash script... Hope someone give me a suggestion... (0 Replies)
Discussion started by: ryanW
0 Replies

8. Shell Programming and Scripting

Need Script to Use CPUs on a HPUX server to simulate Workload Manager on HPUX.

I am running HPUX and using WLM (workload manager). I want to write a script to fork CPUs to basically take CPUs from other servers to show that the communication is working and CPU licensing is working. Basically, I want to build a script that will use up CPU on a server. Any ideas? (2 Replies)
Discussion started by: cpolikowsky
2 Replies

9. Linux

Script to simulate hanging process

I want to create a script to simulate a process that hangs to test a java application. My java app executes a system command, which can also be executing scripts, etc. Any ideas on such a script? The java code is: Runtime rt = Runtime.getRuntime(); Process p = rt.exec("sh... (4 Replies)
Discussion started by: brendan76
4 Replies

10. UNIX for Dummies Questions & Answers

Linux Shell Question: how to print the shell script name ?

Suppose I have a script named "sc.sh" in the script how to print out its name "sc.sh"? (3 Replies)
Discussion started by: meili100
3 Replies
Login or Register to Ask a Question