returning un executed string to shell prompt

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting returning un executed string to shell prompt
# 1  
Old 02-06-2009
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.

# 2  
Old 02-06-2009

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} = "" ]]
  exec ${command}
  printf "\n\n The command '${command}' is not being run. \n\n"

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, Smilie



Last edited by sunpraveen; 02-06-2009 at 03:25 AM..
# 3  
Old 02-06-2009
command underfinded!

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.


# 4  
Old 02-07-2009

You can execute any command by modifying the first line in the script.
command=`echo "[your_command]"


command=`echo "date"`

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux/bash Script only working if executed from shell prompt

Hi, maybe I'm asking a VERY dumb question, but would anybody out there tell me, why this f****** script won't work if executed as a cronjob, but works fine if executed from a shell prompt? #! /bin/bash set PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin date >>... (3 Replies)
Discussion started by: beislhur
3 Replies

2. Shell Programming and Scripting

Shell script not getting executed

Hi As per my requirement when I run . ./ am getting the following error -bash:ELF: command not found when i execute as ./ it is getting executed.How to resolve this. Thanks in advance. (3 Replies)
Discussion started by: pracheth
3 Replies

3. UNIX for Advanced & Expert Users

Procedure to be executed from shell scripts

Hi, I am looking for a script wherein i will be able to execute below procedures one by one in line and next procedures starts only when the previous one completes and also after execution of each procedure i will be getting a automted mail as "PL/SQL PROCEDURE SUCCESSFULLY EXCETUTED". ... (1 Reply)
Discussion started by: sv0081493
1 Replies

4. AIX

Script not getting executed via cron but executes when executed manually.

Hi Script not getting executed via cron but executes successfully when executed manually. Please assist cbspsap01(appuser) /app/scripts > cat #!/bin/ksh cd /app/bin date >>logfile.out echo "Restart has been started....." >>logfile.out date >>logfile.out initfnsw -y restart... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

5. Programming

Returning local string value from a function in C

Hi, If I have a code like this, what are the potential problems do you see? const char* const retString() { return "hello"; /* string literal */ } My questions are: a) Since the string literal which is already a constant read only data (cannot be... (4 Replies)
Discussion started by: royalibrahim
4 Replies

6. Programming

Problem returning string

Hi all, I have been trying with RSA encryption and decryption. I was able to write a code which worked fine. Then I split it into functions as part of a requirement. However I am not getting the expected result everytime. I know it has something to do with how I am returning but it just does not... (1 Reply)
Discussion started by: Treasa
1 Replies

7. Shell Programming and Scripting

Verifying if the shell command executed or not?

Hi, I am working on a shell script that would verify if the mount command has executed or not. So , i have been doing this. mount /dev/cdrom /mnt/cdrom echo "$?" if ; then echo " Mount succesful" else echo " Mount unsuccessful" fi (3 Replies)
Discussion started by: eamani_sun
3 Replies

8. Shell Programming and Scripting

How to get the exit satus of a command which I executed in sftp prompt

Hi All, I need the exit status of a command which is executed through sftp connection. Example: sftp user@host <<EOF mkdir /home/karteek/testing put /home/xyz.txt /home/karteek/testing EOF ------ In the above example, I need the exit status of the put command. Please help me. ... (2 Replies)
Discussion started by: Karteek
2 Replies

9. AIX

Help - Need simple example of VI executed in shell script

Please help - I have seen others ask this question but I need a simple example of using vi in a shell script. Once I enter VI the shell script does not execute the next commands until I q!. I invoke VI and start the edit process. I want to go to the third line and replace a character with a new... (2 Replies)
Discussion started by: corsart
2 Replies

10. Programming

string returning function

I have two string returning function in ESQL/C char *segment_name(lbuffer) char *lbuffer; {..... and char *get_bpdvalue(f_name) char *f_name; {...... both declared above main() char *get_bpdvalue(); char *segment_name(); my problem is segment_name works on sprintf and strcpy... (5 Replies)
Discussion started by: jisc
5 Replies
Login or Register to Ask a Question

Featured Tech Videos