The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
execute a command silently or quietly within a shell lumix Shell Programming and Scripting 4 12-15-2007 11:10 AM
execute shell command in perlscript amitrajvarma Shell Programming and Scripting 0 11-26-2007 10:49 PM
Execute internal script as different user aubtc Shell Programming and Scripting 6 09-12-2007 09:51 AM
Maint user cannot execute ping command kabeer_n UNIX for Dummies Questions & Answers 3 10-23-2006 08:01 PM
How to execute shell Script? siva Shell Programming and Scripting 3 05-14-2002 08:07 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 1
Question shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out?

#!/usr/bin/ksh

test="cal > /tmp/tmp.txt 2>&1"
$test


I know it will work for the following format:

#!/usr/bin/ksh

cal > /tmp/tmp.txt 2>&1

However, I need to get the command from the user in my script, so I have to save this command including arguments in a variable.

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 183
eval $test
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0