{"id":2137,"date":"2022-08-30T15:22:21","date_gmt":"2022-08-30T15:22:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/02\/problem-about-ksh-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:21","modified_gmt":"2022-08-30T15:22:21","slug":"problem-about-ksh-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-ksh-collection-of-common-programming-errors\/","title":{"rendered":"problem about ksh-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a74d859f6f39a29f52d6590e16ef054a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nasc99c<br \/>\nc linux ubuntu ksh<br \/>\nI&#8217;ve got a fairly well tested bit of an application I&#8217;m trying to get working on Ubuntu Linux, and having a lot of problems, seemingly with the ksh implementation. The problem seems to manifest when it is being called by the system build command.There is a ksh script which auto-generates a C header file from a C source file. When I try to run it via a system() call in a C application, the ksh crashes with a segfault.At the command line, I can run the command without problems, and it works corr<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/670e94d3234bfb7e04785f64da8b74b3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChris Aldrich<br \/>\nshell-script ksh error-handling<br \/>\nI am a database administrator working with DB2 on AIX. (Please continue to read as this is related more to ksh than DB2, otherwise I would have posted this over on dba.stackexchange.com.) I am attempting to write up ksh scripts for several of our database deployment as well as database maintenance scripts.I am in the process of putting error handling in our scripts to know whether or not something requires a hard fail or just a warning message, or can be ignored.With most AIX\/ksh related tasks I<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3aa1eca977b2eb18c2fd1d1adc765a2b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nrahmu<br \/>\nsolaris ksh file-descriptors ulimit<br \/>\nI&#8217;m working on an old legacy application, and I commonly come across certain settings that no one around cam explain.Apparently at some point, some processes in the application were hitting the max number of files descriptors allowed per process, and the then team decided to increase the limit by adding the following to the init files of their shells (.kshrc):((nfd=16#$(\/etc\/sysdef | grep &#8220;file descriptor&#8221; | awk &#8216;{ print $1 }&#8217; | cut -f3 -d &#8220;x&#8221;)))ulimit -n $nfdThis increases the output of ulimit<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/be5e929bfcc25f6fdbab21ae753adc9f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChris J. Kiick<br \/>\nksh<br \/>\nI have a program that crashes. I know it does, it&#8217;s supposed to in order to test some trap handling. The crash is expected behavior.When I run the program from ksh, the shell insists on printing helpful little messages like:.\/fpe.ksh: line 9: 105778: Floating exceptionHow do I make it stop that? I want the shell script to ignore the crash and keep going, without the error message.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/393cd3c51f7bb3ef47c520b279b07c5c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndrew G.<br \/>\nlinux shell unix ksh cat<br \/>\nI used the following command in my unix box.$ cat kshAnd it gave a rolling log of latin and greek letters and symbols and it kept on going with no signs of stopping. Eventually I had to close my connection tool to stop it.I was just wondering what was it displaying?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7e38f87eefc12502a7570ab4f062888d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDave<br \/>\nsolaris unix-shell ksh<br \/>\nOur outsourced IT service provider runs the following script via cron to clean up Oracle core and trace files. It clearly is not a well-written script, but my question for the Serverfault crowd is whether there is an error or boundary condition that would have it remove other directories, such as these: \/ora\/admin\/SCRM01P\/bdump \/ora\/admin\/SCRM01P\/cdump \/ora\/admin\/SCRM01P\/pfile \/ora\/admin\/SCRM01P\/udumpWe recently had these directories deleted on a production system, crashing Oracle. Have a loo<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a717291747c76567bb0f086e15ae6e43?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGilles<br \/>\nbash ksh error exit error-handling<br \/>\nSimilarly to set -e performs an exit on &#8220;uncaught&#8221; $? != 0, I&#8217;d like to have this event trigger the execution of another command, e.g. a logger call. How can this be done?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/425fed56a46504d37ec907d99b09ecde?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nl0b0<br \/>\nshell ksh<br \/>\nAs per my knowledge, to determine the current shell we use echo $0 in the shell. Rather I want my script to check in which shell it is running. So, I tried to print $0 in the script and it returns the name of the script as it should. So, my question is how can I find which shell is my script running in during runtime?<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/46a0648d1e6d1b183ce62e657f924502?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHenk Langeveld<br \/>\nshell script classpath ksh<br \/>\nI have to execute the below scriptexport CPATH=&#8221;cpath=.:\/mdcode\/mtrxmdsb2\/WaferChecks\/bin\/WaferChecksFile.jar&#8221; \/sail\/lpp\/IBM\/Java\/1.6.0\/jre\/bin\/java \\-classpath &#8220;$CPATH&#8221; com\/ibm\/md\/waferchecks\/ReadPasswordMain $1 $2 $3The script accepts 3 arguments. But when im running the script from the cmd prompt, I am getting the following error:Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: com.ibm.md.wafercheck s.ReadPasswordMain Caused by: java.lang.ClassNotFoundException: com.ibm.md.waferchec<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/46a0648d1e6d1b183ce62e657f924502?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHenk Langeveld<br \/>\nwindows cygwin ksh<br \/>\nAlways i get &#8220;Source file not readable or exists, please check the file &#8221; for the below code. I use cygwin in my windows machine to run the script. I am getting the same message even when the file is present in the location. How can i get more details as why the file is not readable.#!\/bin\/ksh # # Scanning source file for existance and readable file_loc=&#8221;abc.xml&#8221; if [ -f &#8220;$file_loc&#8221; -a -r &#8220;$file_loc&#8221;] thenprint &#8220;Source file read.\\n&#8221; elseprint &#8220;Source file not readable or exists, please check the<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ffbf4e85b8ffbae4e9039b9c0cf07bc8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\n4 revs, 2 users 100%Nano Taboada<br \/>\njava unix jsp shell ksh<br \/>\nFirst and foremost I should acknowledge that I have no experience at all using Java ServerPages, but I&#8217;m positive about achieving this task if you guys help me out a bit since it doesn&#8217;t seem like something difficult for a seasoned JSP programmer.Anyway the thing is, there&#8217;s an actual running JSP application within a *NIX box which I somewhat administer with kind of good permissions. The idea is to create a new but dead simple JSP page to control some Korn Shell scripts I&#8217;ve got running there. S<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f421285f45fc6d8d679b198dd318f35f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBert F<br \/>\nbash unix shell ksh<br \/>\ni am testing with the shell script below:#!\/bin\/ksh -xinstance=`echo $1 | cut -d= -f2` if [ $instance == &#8220;ALL&#8221; ] then echo &#8220;strings matched \\n&#8221; fiIt&#8217;s giving this error in the if condition:: ==: unknown test operatoris == really not the correct syntax to use? I am running on the command line as belowtest_lsn_2 INSTANCE=ALLCould anybody please suggest a solution. Thanks.<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/297b31165c5ef426c8fa89c3375b0d2a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndsolimano<br \/>\nksh sua<br \/>\nI am using SUA-Korn shell on Windows where in I have set an alias in .profile as alias sqlplus=&#8217;sqlplus.exe&#8217;So when I start SUA-Korn shell and run sqlplus it calls sqlplus.exe and works fine but when I put same command in .ksh file and run it gives error that &#8216;unknown command sqlplus&#8217; Below is .ksh file#!\/bin\/ksh sqlplus main\/main@SID9 @script.sqlIf I execute above test.ksh in SUA-Korn shell as. test.ksh then it works fine buttest.kshgives unknown command sqlplus.Thanks In Advance<\/li>\n<li>\n<img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c60fa6c056483ed976574bdeaf9422b1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBernard Assaf<br \/>\nksh readonly typeset<br \/>\nI wish to source a script, print the value of a variable this script defines, and then have this value be assigned to a variable on the command line with command substitution wrapping the source\/print commands. This works on ksh88 but not on ksh93 and I am wondering why.$ cat typeset_err.ksh #!\/bin\/ksh unset _typeset_var typeset -i -r _typeset_var=1 DIR=init # this is the variable I want to printWhen run on ksh88 (in this case, an AIX 6.1 box), the output is as follows:$ A=$(. .\/typeset_err.ksh<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2014-01-02 12:08:52. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>asc99c c linux ubuntu ksh I&#8217;ve got a fairly well tested bit of an application I&#8217;m trying to get working on Ubuntu Linux, and having a lot of problems, seemingly with the ksh implementation. The problem seems to manifest when it is being called by the system build command.There is a ksh script which auto-generates [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2137","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2137"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2137\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}