Sponsored Content
Top Forums Shell Programming and Scripting returning un executed string to shell prompt Post 302284638 by sunpraveen on Friday 6th of February 2009 02:12:27 AM
Old 02-06-2009
John,

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

Code:
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:
Code:
$ ./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

Regards,

Praveen

Last edited by sunpraveen; 02-06-2009 at 03:25 AM..
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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 restart.sh #!/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

8. 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

9. Shell Programming and Scripting

Shell script not getting executed

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

10. 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
CONFMODULE(3)						     Library Functions Manual						     CONFMODULE(3)

NAME
confmodule - communicate with Debian configuration system FrontEnd. SYNOPSIS
#!/bin/sh -e . /usr/share/debconf/confmodule db_version 2.0 db_capb 'backup' CAPB=$RET db_input 'foo/bar' || true db_go || true DESCRIPTION
This is a library of shell functions that eases communication with Debian's configuration management system. It can communicate with a FrontEnd via the debconf protocol. The design is that each command in the protocol is represented by one function in this module. The func- tionname is the same as the command, except it is prefixed with "db_" and is lower-case. Call the function and pass in any parameters you want to follow the command. Any textual return code from the FrontEnd will be returned to you in the $RET variable, while the numeric return code from the FrontEnd will be returned as a return code (and so those return codes must be captured or ignored). NOTES
Once this library is loaded, any text you later output will go to standard error, rather than standard output. This is a good thing in gen- eral, because text sent to standard output is interpreted by the FrontEnd as commands. If you do want to send a command directly to the FrontEnd, you must output it to file descriptor 3, like this: echo GET foo/bar >&3 The library checks to make sure it is actually speaking to a FrontEnd by examining the DEBIAN_HAS_FRONTEND variable. If it is set, a Fron- tEnd is assumed to be running. If not, the library turns into one, and runs a copy of the script that loaded the library connected to it. This means that if you source this library, you should do so very near to the top of your script, because everything before the sourcing of the library may well be run again. SEE ALSO
debconf-devel(7), dpkg-preconfigure(8), dpkg-reconfigure(8), debconf_specification in the debian-policy package AUTHOR
Joey Hess <joeyh@debian.org> CONFMODULE(3)
All times are GMT -4. The time now is 10:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy