ksh

Different pipeline behavior between sh and ksh

混江龙づ霸主 提交于 2019-12-08 05:42:21
问题 I have isolated the problem to the below code snippet: Notice below that null string gets assigned to LATEST_FILE_NAME='' when the script is run using ksh ; but the script assigns the value to variable $LATEST_FILE_NAME correctly when run using sh . This in turn affects the value of $FILE_LIST_COUNT . But as the script is in KornShell (ksh), I am not sure what might be causing the issue. When I comment out the tee command in the below line, the ksh script works fine and correctly assigns the

A Perl system call must send exactly both characters single & double quote ' \"

左心房为你撑大大i 提交于 2019-12-08 05:10:29
A Perl system call must send the following string to the UnixShell : '"XYZ"' In my Perl script I have used the following command: system("cleartool mkattr -replace ATTRIBUTE '"$attribute"' lbtype:$label"); Everything is well passed to the Shell Unix , except both uses of the quote character: ' Indeed, cleartool mkattr -replace ATTRIBUTE The above command is passed as it is exactly what I want. The Perl variables $attribute and $label are well interpreted. But I don't know what to do to obtain exactly: '"XYZ"' Here XYZ is the value of the Perl variable $attribute OS is AIX (Unix) and Shell is

Check FTP Success-Failure Inside KornShell Script

冷暖自知 提交于 2019-12-08 04:57:25
问题 Wondering what are some of the right ways to check whether File Transfer Protocol (FTP) succeeded or not inside the KornShell (ksh) script. 回答1: There are so many ftp-clients AND many of there do not necessarily follow std return conventions that you have to do some simple tests, and then code accordingly. If you're lucky, your ftp-client does return std exit codes and they are documented via man ftp (You do know about man pages?). In that case, 0 means success and any non-zero indicates some

How to reverse a string in ksh

允我心安 提交于 2019-12-07 18:55:13
问题 please help me with this problem, i have an array witch includes 1000 lines with number which are treated as strings and i want for all of them to reverse them one by one, my problem is how to reverse them because i have to use ksh or else with bash or something it would be so easy..... what i have now is this, but rev="$rev${copy:$y:1}" doesnt work in ksh. i=0 while [[ $i -lt 999 ]] do rev="" var=${xnumbers[$i]} copy=${var} len=${#copy} y=$(expr $len - 1) while [[ $y -ge 0 ]] do rev="$rev$

redirect plsql error message to a log file when executing it in sqlplus

匆匆过客 提交于 2019-12-07 16:48:39
问题 Need a way to redirect PL/SQL program error message to a log file when executing it in sqlplus. Say the PL/SQL program is named send_2012.sql and it has the following exception block EXCEPTION WHEN NO_DATA_FOUND THEN var_err := 'Data not found. '; WHEN OTHERS THEN var_err := 'Error in ' || $$plsql_unit || ' | ' || SQLERRM || ' | ' || 'Details: ' || DBMS_UTILITY.format_error_backtrace; END; To run the PL/SQL program in a KornShell (ksh) script, I have: sqlplus some_username/'some_password'

for loop range not working ksh

我是研究僧i 提交于 2019-12-07 16:47:49
问题 I tried this, #!/bin/ksh for i in {1..10} do echo "Welcome $i times" done in Ksh of an AIX box. I am getting the output as, Welcome {1..10} times What's wrong here? Isn't it supposed to print from 1 to 10?. Edit: According to perkolator's post, from Iterating through a range of ints in ksh? It works only on linux. Is there any other work around/replacements for unix box ksh? for i in 1 2 3 4 5 6 7 8 9 10 is ugly. Thanks. 回答1: I think from memory that the standard ksh on AIX is an older

Difference between test -h and test -L

落花浮王杯 提交于 2019-12-06 19:39:23
问题 What is the difference between test -L filename and test -h filename in ksh shell. From the man page, both were used to identify a symbolic link, but I want to know the exact difference. Here is the description from the man page. -h file True if file exists and is a sym- bolic link. -L file True if file exists and is a sym- bolic link. 回答1: The source code for ksh93 , in file bltins/test.c , shows that these two options are treated exactly the same, except for the author's hopes for the

ORA-01741: illegal zero-length identifier

最后都变了- 提交于 2019-12-06 17:12:17
问题 Hi I am using a delete query in my shell script and I am facing this issue. delete from WHITELIST_CLI where filecode like'%Line_Index_condense%'; Error: ERROR: ORA-01741: illegal zero-length identifier 回答1: Here is some information on the error: ORA-01741: illegal zero-length identifier Cause: An attempt was made to use two double quotes ("") as an identifier. An identifier must be at least one character long. Your query has nothing of the sort. This may be an interaction between ksh and

connect to sqlplus only once without writing to a file in a loop

这一生的挚爱 提交于 2019-12-06 12:09:02
问题 I have a requirement for which I need to write a ksh script that reads command line parameters into arrays and creates DML statements to insert records into an oracle database. I've created a script as below to achieve this. However, the user invoking the script doesn't have permission to write into the directory where the script has to run. So, is there a way we can fire multiple inserts on the database without connecting to sqlplus multiple times within the loop and at the same time, NOT

How to read just a single character in shell script

浪子不回头ぞ 提交于 2019-12-06 10:34:29
问题 I want similar option like getche() in C. How can I read just a single character input from command line? Using read command can we do it? 回答1: In ksh you can basically do: stty raw REPLY=$(dd bs=1 count=1 2> /dev/null) stty -raw 回答2: In bash, read can do it: read -n1 ans 回答3: read -n1 works for bash The stty raw mode prevents ctrl-c from working and can get you stuck in an input loop with no way out. Also the man page says stty -raw is not guaranteed to return your terminal to the same state