returning un executed string to shell prompt

Hi all, i'm pritty new to chell scripting

I'm trying to find a way to return a value to shell without it executing. is there a special character that will encase a sting including the command to a shell without executing, so waiting for the user to press enter.

say i wanted to return a value like "cd /usr/mydocs/mywrk/thedate/" but just have it sit in the shell.

anyway is this possible or am i waisting my time here

any answers would be greatly apreciated.

john

John,

Try the below code. Let me know if it works.

command=`echo "date"`

echo "Do you want to execute the command '${command}:'"
read RET

if [[ ${RET} = "" ]]
then
  exec ${command}
else
  printf "\n\n The command '${command}' is not being run. \n\n"
fi

Sample Output:

$ ./test1
Do you want to execute the command 'date:' ## Hit return (ENTER) without inputting anything.

Fri Feb  6 01:16:36 CST 2009

$ ./test1
Do you want to execute the command 'date:'
Y ## ## Input Y (or anything for that matter) and the else part of the if condition is executed.


 The command 'date' is not being run.

$

HTH, :cool:

Regards,

Praveen

hey man thats for that. all i get it a error

i'm using tsch

command=who: Command not found.
command: Undefined variable.

so i set up an Alias to source the script in my .cshrc file.

then i just ran in using that alias in my shell.

is there something i'm missing. i'm a newbee so it could be something really simple i'm doing wrong.

cheers

john

John,

You can execute any command by modifying the first line in the script.

command=`echo "[your_command]"

eg:

command=`echo "date"`