0

While running my script, I got the following message (it's not an error strictly speaking, because the execution go ahead after) :

myScript -s test -u test2
pk_copylogs[2]: hist: :: not found

However, do you know why does this message appear ?

6
  • Run it with ksh -x myScript -s test -u test2 2>&1 | sed -n l > some-file and look in some-file for what is being done just before the error. Nov 18, 2013 at 15:16
  • Also, when asking for help about a script's error, ALWAYS include the relevant lines from the script.
    – terdon
    Nov 18, 2013 at 15:52
  • I agree, but thus I don't know what is this error about, I don't know what goes wrong with my script, and which lines are prolematic. Nov 18, 2013 at 15:57
  • Show us the script! Nov 18, 2013 at 21:51
  • pk_copylogs looks like another script, but might even be a shell function - correct? Nov 18, 2013 at 23:10

3 Answers 3

2

The hist command is a korn shell (ksh93) builtin, and is not available in bash.

Your script(s) appears to be running under bash, not ksh.

ksh$ command -V hist
hist is a shell builtin   

bash$ command -V hist
bash: command: hist: not found

Try the following:

$ ksh myScript -s test -u test2

or:

$ SHELL=ksh ksh myScript -s test -u test2

However, hist is a command that's typically only used in interactive mode, and I would not expect it in a script. It is rarely invoked directly, and more often as one of the following aliases:

$ alias | grep hist
fc=hist
history='hist -l'
r='hist -s'        

Look for any of fc, history, r.

2
  • 1
    It works. Actually, it was the line author : ... which wasn't commented. Thank you. Nov 19, 2013 at 7:31
  • fc used to be the original command history editor. Nov 19, 2013 at 14:52
0

In your myScript code, there is a call to another external script called pk_copylogs. On the second line of the pk_copylogs, there is an assumption that you have a command called hist accessible from anywhere, i.e., in one of the directories included in your $PATH variable.

The most likely cause of this problem is, in most shells I have worked with which I didn't have to configure my shortcuts, but someone prior to me did, the command hist is aliased to command history for the convenience purposes. But when you launch a shell script, that alias goes out the window. Of course your case might be totally different but without seeing the actual code of these two scripts you referenced, i.e., myScript and pk_copylogs, it is very hard to make any assertions

0

Have a look to the second line of the fc_copylogs script, this is the one that trigger the error message.

Here is one way to reproduce exactly the same message you got:

$ cd /tmp
$ cat > pk_copylogs <<%
#!/bin/ksh
fc $1
%
$ chmod +x /tmp/pk_copylogs
$ PATH=$PATH:/tmp pk_copylogs ::
pk_copylogs[2]: hist: :: not found

Of course, it might not be exactly the same situation in your case but it is certainly very close.

The second line of pk_copylogs might simply contain this line

hist ::

which would produce the very same error message, or anything that would expand to it.

If you have no idea about where to look, you can run this command to locate the faulty script:

find / -name pk_copylogs -print 

and then have a look to its first lines with

head /path/to/pk_copylogs

Not the answer you're looking for? Browse other questions tagged .