Questions tagged [ksh]

The Korn shell (ksh) is a shell with advanced scripting features, commonly found on commercial unices and some BSD systems but rarely used on Linux.

0
votes
1answer
27 views

AIX restricted shell add entry to inittab

Need a help in adding an entry to the AIX inittab on VIO server. The VIO server is a restricted shell, to add entry to the inittab we need to access the root shell using command: oem_setup_env. I'm ...
0
votes
0answers
32 views

Creating data delimited by ASCII code 1

Any suggestion how to create a file where the values are separated by ASCII code 1,with data extracted from a table? The format is : columnname1(binary1)columnvalue(binary1)columnname2(binary1)...
0
votes
0answers
23 views

How to append the output variables of a shell script to excel file

I have a script that runs daily at 11 PM and produces variables $endofday_A which will have value "20:03:06" $endofday_B which will have value "20:06:07" $endofday_C which will have value "20:05:25" ....
0
votes
1answer
35 views

Why does “if tty -s” work but “if [ tty -s ]” does not?

Note, I am using ksh and running in CentOS. I have a shell script where a logger function is set like: if tty -s then echo "${FOO}" | tee -a ${BAR_LOG_FILE} else echo "${FOO}" >> ${...
1
vote
1answer
19 views

Adding a NEW LINE character in between variables

How can I add a new line character (\n) between two Unix variables? I tried the following but it's getting printed in a single line instead of separate lines. h=hello w=world c="$h"$'\n'"$w" echo $c ...
0
votes
2answers
57 views

Converting bash to ksh

My current shell is bash and I want to convert to ksh. I tried to convert through chsh or ypchsh but dont have permission to convert. So I tried to convert using .bash_profile as below $vi ....
0
votes
0answers
71 views

problem listing files from sftp

I am having difficulties trying to list out files based upon file pattern with respect to files that have spaces. Below is my terminal status. What I want to do is get a list of files from a given ...
0
votes
1answer
14 views

Replace patterns in a string

how can I replace every comma within a string with the following string Single quote comma single quote Example: US1,US2,US3 -> US1','US2,','US3 I tried using the following command a=US1,US2 ...
5
votes
3answers
257 views

How to find out if there are files in a folder and exit accordingly (in KSH)

I have a KSH (not Bash) script that I want to preempt with a file count check. If there's no files I want to print "EMPTY" then exit. Otherwise proceed. The problem is when I perform the file count, ...
0
votes
1answer
27 views

List files which are transferred by sftp [closed]

Can we list the files which are transfered via sftp be listed ?
0
votes
2answers
100 views

How to feed data through pipe into utility/command as part of shell here-doc?

The following example is kind of classical way of using pipes. On right side of pipe we have a "simple" utility which reads data from stdin (pipe) and prints to stdout in reverse order: { cat <<...
0
votes
1answer
34 views

Variable substitution in Unix environment variable name

I have set the following Unix environment variables. export Dev_Branch=temp export QA_Branch=stage export Prod_Branch=master Now I am taking the environment name as input to my script and I need to ...
3
votes
1answer
55 views

Exit status of command in pipeline

I have come across this code but cannot understand exec >&p edit 1 to my understanding : #! /usr/bin/ksh exec 4>&1 ## standard output is first saved as file descriptor 4 ...
1
vote
0answers
50 views

RH7 ksh wait not working

I have some ksh shell scripts that I ported from RedHat 4 to RH7. I have bar.ksh #!/bin/ksh # here I start another script foo.ksh args & # one process with a given set of args foo.ksh args & ...
0
votes
1answer
42 views

Ambiguous error while executing ksh file

I have created a audit.ksh file which is used to clear old "*.aud" files. But when i run this file am getting below error. The strange thing is the commands inside the file works fine while executing ...
7
votes
2answers
957 views

How to produce a PS1 prompt in bash or ksh93 similar to tcsh

In tcsh, I have the default: prompt [%m:%c3] %n%# which gives prompts like: [woehler:hacking/c/hello] ajcarr% and [woehler:~] ajcarr% In other words, the current directory and up to the next ...
1
vote
1answer
40 views

Unable to find regular file with default shell as bash but works when it's ksh

We have script file FileChecker.sh where it checks whether file exists or not FileChecker.sh content: #!/bin/ksh FILE=$1 FILE2=$2 if [[ "$FILE" == "" || "$FILE2" == "" ]] ; then echo "[ERROR] ...
1
vote
2answers
92 views

script with date work on Linux but not on AIX

I wrote a script to that works fine on Linux but fails on AIX 7.2. My script uses the command date with -d. The purpose of this script is to get the last day that is not a Saturday, Sunday or a ...
-1
votes
3answers
79 views

Iterate print for each line in output

I want to print uvuveve at finish each line, for each output into while statement, as below: var1;var2;uvuveve var1;var2;uvuveve var1;var2;uvuveve var1;var2;uvuveve var1;var2;uvuveve This is my code:...
0
votes
1answer
49 views

Getting find: bad option -o -name abc -o -name xyz when perform search for *.properties excluding set of directories from search [closed]

#!/usr/bin/ksh # ***************************************************************************************** # copy_properties.sh # This script copies *.properties files from all directory excluding ...
0
votes
1answer
41 views

Assigning a variable within a while loop in shell script

I am trying to assign a variable within a while loop and the script hangs during the read statement. while read -r port 60720 60721 60722 60723 60724 here is the code: qmgrs=$($MQ_INSTALL_PATH/...
1
vote
1answer
104 views

IF statement AIX (Korn Shell Script)

I've made a script which collects info. One of the things it does is checking if a file or directory exists. If yes, it copies it to the /tmp directory. The script fails with 0403-057 Syntax ...
5
votes
3answers
1k views

Equivalent to “source” in OpenBSD?

Trying to open a python3 virtual environment I have created with python3 -m venv myVenv by doing source myVenv/bin/activate as I do in Linux, but I get ksh: source: not found which mean it is ...
0
votes
1answer
59 views

elif statement is not getting executed in unix shell script

#!/bin/ksh print -n "\nEnter the client ID : " read clientID print $clientID data=$(grep jms/erms/$clientID /export/home/a0706838/test.txt;) print "\n $data" getClientID=$(echo "$data" | awk '{...
0
votes
2answers
75 views

How could I know inside a script if stdout has been redirected for it?

I have a script in ksh; depending whether there is a redirection from the command line, I redirect the output via a exec 1>file. How can I test from inside the script itself if the command calling ...
-2
votes
2answers
36 views

use the file contents line by line and execute [closed]

file.txt servername1:DBNAME1:/u01/app servername2:DBNAME2:/u01/dbs servername3:DBNAME3:/u01/app1 I want to use above file contents line by line and execute it in shell script command1 hostname=...
-2
votes
1answer
48 views

Extract string followed by specific word/symbol

I have two lines as shown below in my input file input.txt and I need to extract claimStartDate from first line and claimEndDate from second line. <ProfessionalClaim paymentIndicator="P" ...
-1
votes
1answer
179 views

Perl script not found when executed from a different directory than the current one

I am using perl64 on Windows 10 with UWIN installed. I wrote a perl script, sv2jb.pl, which runs fine when invoked under ksh by just typing its name, and when it is in the current directory. I then ...
3
votes
2answers
96 views

A Unix AIX variable without a $ symbol?

I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it. Values are: dt_val=1234 prev_dt_val=1234 If condition goes like: if [ dt_val -eq prev_dt_val ] ...
0
votes
1answer
41 views

korn shell Unable to substitute ' ' (2 quotes) with ' (single quote) in a string variable

I am trying to substitute ''2019-01-14'' to '2019-01-14' in a varible $STG. I tried various techniques echo ${STG//''/'} echo $STG | sed -e s/'\'\''/'\''/g many more none of the equations are ...
0
votes
3answers
48 views

unix awk match a string and perform delimiting

I'm checking the ping connectivity checks from a host and that would ssh to another jump host and will perform ping communication. I would like to print the successful packets pinged count using awk. ...
0
votes
2answers
49 views

Move the oldest files into a directory, source directory has more than 10,000 files constantly incoming

I am working on a command to move the x number of oldest files(FIFO) into a directory, is it better idea to pipe the "find" result into "ls" or just use the "ls" .. please suggest. ls -ltr `/bin/...
1
vote
0answers
21 views

AIX 6.1 versus AIX 7.1 strange behaviour [duplicate]

I have this logic in a ksh script on AIX 6.1 and it works fine. integer loop_count=0 integer sleep_interval=5 integer alarm_interval=60 if (( $loop_count*$sleep_interval%$alarm_interval -eq 0 )) then ...
0
votes
2answers
82 views

Extracting part of string from a file in ksh environment

I have a file that has error messages as per below rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1505) rsync error: error in rsync protocol data ...
1
vote
1answer
23 views

update params of variable ksh88 [closed]

I'm trying to update a variable: FLUX=first DATE=`date +%Y%m%d_%H_%M` justName=$FLUX DIR_LOG=$REP_LOG_TD/DDL_TABLES_LOG/$justName'_'$DATE if [ condition ] then justName=other DIR_LOG=$DIR_LOG fi ...
1
vote
1answer
181 views

Align columns evenly without “column - t”

I have an output file created from a Korn shell script. I need to align the output with spaces evenly. Unfortunately column -t is not available on AIX. Actual File: X1vir1000 x1-DFB127 ...
0
votes
1answer
104 views

How can I adapt this bash progress bar function for AIX ksh88? [closed]

I have a bash script for progress bar and I use it when I work in bash: #!/bin/bash prog() { local w=80 p=$1; shift printf -v pt "%*s" "$(( $p*$w/100 ))" "";pt=${pt// /.}; printf "\r\e[...
0
votes
2answers
31 views

How to sum value of specified column by specific date in kornshell?

I'm working in a unique validation framework that validates data. For each validation job there is a SQL job with an accompanying KSH job (kornshell). The SQL queries something in the database, and ...
2
votes
1answer
54 views

Does ksh93 support +o type options with its getopts(1) builtin?

ksh93 supports long options the same way as introduced by Sun Microsystems in Spring 2004 for getopt(3), Bourne Shell and ksh88. You may e.g. use: getopt(argc, argv, "V(version)"); to establish a ...
1
vote
0answers
33 views

ksh keybind trap

I am trying to follow this code sample http://www.kornshell.com/examples/keybind # Example from page 98 typeset -A Keytable trap 'eval "${Keytable[${.sh.edchar}]}"' KEYBD function keybind # key [...
5
votes
0answers
83 views

Correct treatment of quotes in parameter expansions

Using the default value of IFS, consider unset var set -- ${var:-"hello"} echo "$#" This prints 1 as the parameter expansion expands to the single string hello. unset var set -- "${var:-"hello"}" ...
0
votes
0answers
25 views

How to iterate pattern by other one?

I have the bellow output. I try to iterate same times the Date and Time: Month Day Year HH:MM:SS for each Application n.n string found it. =========================================================...
1
vote
0answers
61 views

ksh while loop issue

In ksh, I have a while loop that reads two files. If current line of file 1 is Y then echo the current line of file 2 into new file and if current line of file 1 is N echo the string waste in winscp. ...
-1
votes
1answer
39 views

Find Command, I want to use my variables

I have a script that creates a new directory based on User Input, and well as which directory contents it will copy over. Now here is where I am having issues, I have a find command that will replace ...
2
votes
1answer
398 views

OpenBSD - How does one set an alias?

I am running the latest OpenBSD and I cannot figure out how to set a simple alias, something along the lines of cls=clear. I've tried putting it in ~/.cshrc and in ~/.profile. I've tried: alias cls ...
-1
votes
2answers
34 views

file permission error when checking filename in ksh

I'm trying to create a checksum file. The file will have a list of files from the working directory, create cksums for each file, and drop the list of files with their cksums as MD5_<>.txt along ...
1
vote
1answer
255 views

Using korn shell to compare local and remote MD5 over sftp

I am in need of creating and checking checksums between a local file, and the remote file I just pushed. If the MD5 checks, continue, else break. This needs to be in KORN shell scripting because we ...
3
votes
1answer
54 views

How to test if IFS is unset in ksh93?

It seems easy to test if a variable is unset. I know of three ways at least: #!/bin/ksh unset var [ "$#" -gt 0 ] && var=$1 [ "${var+set}" != "${var}" ] && echo set1 || ...
2
votes
2answers
900 views

Removing characters with sed [duplicate]

I am working on AIX unix and trying to remove non-printable characters from file the data looks like Caucasian male lives in Arizona w/ fiancÃÂÃÂÃÂÃÂÃÂ in file when I view in Notepad++ using UTF-8 ...
3
votes
1answer
74 views

chfs does not work in a login ksh shell [closed]

I can't find a reason why chfs command fails in ksh (I open ssh sesion with putty). But when I run ksh or ksh93 in the shell again then it works. Any clues? # alias|grep chfs # type chfs chfs is /...