Get the exit code for a command in Bash and KornShell (ksh)

Below is the fixed code: #!/bin/ksh safeRunCommand() { typeset cmnd=”$*” typeset ret_code echo cmnd=$cmnd eval $cmnd ret_code=$? if [ $ret_code != 0 ]; then printf “Error: [%d] when executing command: ‘$cmnd'” $ret_code exit $ret_code fi } command=”ls -l | grep p” safeRunCommand “$command” Now if you look into this code, the few things that I … Read more

Pipe input into a script

Commands inherit their standard input from the process that starts them. In your case, your script provides its standard input for each command that it runs. A simple example script: #!/bin/bash cat > foo.txt Piping data into your shell script causes cat to read that data, since cat inherits its standard input from your script. … Read more

Bash or KornShell (ksh)? [closed]

The difference between Kornshell and Bash are minimal. There are certain advantages one has over the other, but the differences are tiny: BASH is much easier to set a prompt that displays the current directory. To do the same in Kornshell is hackish. Kornshell has associative arrays and BASH doesn’t. Now, the last time I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)