LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   usage of history command inside shell script (https://www.linuxquestions.org/questions/linux-newbie-8/usage-of-history-command-inside-shell-script-688247/)

bsaheb 12-04-2008 04:36 AM

usage of history command inside shell script
 
Hi All,

I need to write a script which requires to display the output for the shell commands.

I am able to retrieve the result for "ls" but the "history" command execution is failed.

Please let me know if there a way to specify the history command inside the shell script and get the output of it.

Sample Script:

#!/bin/bash
ls
history

Rgrds,
saheb

hasanatizaz 12-04-2008 04:46 AM

remove #!/bin/bash
it will work.

bsaheb 12-04-2008 05:03 AM

Not able to execute the history command.

Please find the error message.

[s9:~]cat a.sh
ls
history

[s9:~]sh a.sh
a.sh logs
bin classes
conf jre
lib local.cshrc
local.login local.profile
a.sh: history: not found
[s9:~]

chrism01 12-04-2008 07:12 AM

Quote:

Note that within a script, the history mechanism is disabled.
http://www.tldp.org/LDP/abs/html/special-chars.html

senthilp 01-05-2010 08:55 PM

change the permission
 
Quote:

Originally Posted by bsaheb (Post 3364063)
Not able to execute the history command.

Please find the error message.

[s9:~]cat a.sh
ls
history

[s9:~]sh a.sh
a.sh logs
bin classes
conf jre
lib local.cshrc
local.login local.profile
a.sh: history: not found
[s9:~]

hi,

give the permission to the script..

chmod 755 a.sh or chmod 777 a.sh

then execute, you will get the output

regards,
senthil.P


All times are GMT -5. The time now is 07:22 AM.