ksh

Multiple rows in single field not getting loaded | SQL Loader | Oracle

让人想犯罪 __ 提交于 2019-12-11 12:07:57
问题 I need to load from CSV file into an Oracle Table. The problem i m facing is that, the DESCRIPTION field is having Multiple Lines in itself. Solution i am using for it as ENCLOSURE STRING " (Double Quotes) Using KSH to call for sqlldr. I am getting following two problems: The row having Description with multiple lines, is not getting loaded as it terminates there itself and values of further fields/columns are not visible for loader. ERROR: second enclosure string not present (Obviously " is

Building Dynamic Variable Names in KornShell

穿精又带淫゛_ 提交于 2019-12-11 11:29:11
问题 I did a search but did not find anything quite like what I am trying to do. I have a list of Server Hostnames & IPs Servera | IPa Serverb | IPb Servern | IPn I want to cat this file and put each element into variables Server_Var_1 IP_Var_1 Server_Var_2 IP_Var_2 Server_Var_n IP_Var_n What I currently have is the following KornShell (ksh): Counter=0 cat hostfile|while read line; do Server_Var_"$Counter"=echo $line | awk -F"|" '{print $1}' IP_Var_"$Counter"=echo $line | awk -F"|" '{print $2}'

grep + match exactly IP address with Regular Expression

别来无恙 提交于 2019-12-11 08:17:52
问题 my target is to match exactly IP address with three octes , while the four IP octet must be valid octet - between <0 to 255> For example I have the following IP's in file $ more file 192.9.200.10 192.9.200.100 192.9.200.1555 192.9.200.1 192.9.200.aaa 192.9.200.@ 192.9.200.: 192.9.200 192.9.200. I need to match the first three octets - 192.9.200 while four octet must be valid ( 0-255) so finally - expects result should be: 192.9.200.10 192.9.200.100 192.9.200.1 the basic syntax should be as

Python: return output of ksh function

邮差的信 提交于 2019-12-11 06:39:24
问题 On Unix, how can Iretrieve the output of a ksh function as a Python variable? The function is called sset and is defined in my ".kshrc". I tried using the subparser module according to comment recommendations. Here's what I came up with: import shlex import subprocess command_line = "/bin/ksh -c \". /Home/user/.khsrc && sset \"" s = shlex.shlex(command_line) subprocess.call(list(s)) And I get a Permission denied error. Here's the traceback: Traceback (most recent call last): File "./pymss_os

bash/ksh/scripting eval subshell quotes

 ̄綄美尐妖づ 提交于 2019-12-11 04:48:29
问题 I'm using ksh and having some trouble. Why does this code not run? [root]$ CMD="ls -ltr" [root]$ eval "W=$( $CMD )" [root]$ ksh: ls -ltr: not found. [root]$ echo $W But this works fine: [root]$ CMD="ls -ltr" [root]$ eval 'W=$('$CMD')' [root]$ echo $W 回答1: You need to escape the $(...) with a backslash to prevent it from being evaluated by the outside shell. The $(...) needs be preserved as is until it is handed off to the eval : $ CMD="ls -ltr" $ eval "W=\$( $CMD )" $ echo $W total 197092

What is the internal processing of $* and $@

ぃ、小莉子 提交于 2019-12-11 04:17:45
问题 Actually, I am fully understand the use of $* and $@. For example, if I run the script using: my_script * Then, for ONE_FILE in $@ will really get each file into ONE_FILE for processing. Even there is space(s) in the filenames, ONE_FILE will get the correct filename. If, however, using for ONE_FILE in $*, the story is different. I think you guys understand the difference and I do not need to go further. Now, what I am interested is HOW. How the KornShell (ksh) interprets the my_scrpt * and

array+=value not work in ksh?

空扰寡人 提交于 2019-12-11 03:17:22
问题 I read somewhere that ksh's array supports += to append new elements, but I tried it and it doesn't work: [ksh] # arr=(a b c d) [ksh] # arr+=e [ksh] # echo ${arr[*]} ae b c d [ksh] # Why does arr[0] becomes ae ? 回答1: To add an element to the array, it should be like this: arr+=(e) By doing arr+=e , it will add to the 1st element of the array. Its because just the name arr points to the 1st element of the array itself: $ arr=(a b c d) $ echo ${arr[0]} a $ echo $arr a 回答2: It's arr+=(e) . Any

How can I find the current date minus seven days in Unix?

人盡茶涼 提交于 2019-12-11 02:41:06
问题 I am trying to find the date that was seven days before today. CURRENT_DT=`date +"%F %T"` diff=$CURRENT_DT-7 echo $diff I am trying stuff like the above to find the 7 days less than from current date. Could anyone help me out please? 回答1: GNU date will to the math for you: date --date "7 days ago" Other version will require you to covert the current date into seconds since the UNIX epoch first, manually subtract 7 days' worth of seconds, and convert that back into the desired form. Consult

array length in ksh always return 1 and why array is not lines

蹲街弑〆低调 提交于 2019-12-10 22:23:28
问题 I need to echo information of a process for a UID in ksh: #!/bin/ksh read userid arr=$(ps -elf | nawk -v pattern=${userid} '{if ($3==pattern) print}') arrlen=${#arr[@]} echo $arrlen for f in "${arr[@]}"; do echo $f done arr is an array of process for this UID. arrlen always equal 1. Why? My second question: I try to echo all elements in arr and output is 0 S s157759 22594 1 0 50 20 ? 2:06 /usr/lib/firefox/firefox-bin instead of 0 S s157759 22594 1 0 50 20 ? 62628 ? 11:14:06 ? 2:06 /usr/lib

ksh “getopts” — Unsetting an Option

Deadly 提交于 2019-12-10 21:39:15
问题 I use the "getopts" ksh built-in to handle command-line options, and I'm looking for a clean/standard way to "unset" an option on the command line. I don't know if this is a technical question about getopts or more of a style/standards question. Anyway, I understand that getopts processes its args (by default $*) from left to right, and I'm hoping to use that to allow a second specification of an option to "turn off" an option. For options that take an option argument, this isn't a problem.