Questions tagged [ksh]

Ksh is the executable name for the Korn shell developed by David Korn at AT&T Laboratories in the early 1980s. It is commonly used in Solaris and is favored for its ability to use Emacs and Vi shortcuts at the command line.

Filter by
Sorted by
Tagged with
0 votes
0 answers
501 views

how to make a shell execute with suid

I'm trying to suid a shell and it's not working. I need help understanding why, and how to fix it... I'm following these steps (as root) cp /usr/bin/bash /usr/bin/bash-emergency chmod 4755 /usr/bin/...
mikem's user avatar
  • 418
1 vote
0 answers
83 views

KSH/Bash History for jailed SSH users

How can I keep a history of activities for chroot'd SSH (not SFTP) users? I've tried: created a .sh_history in their home with the proper permissions created a custom $HISTFILE in .profile and in its ...
Dumb  admin's user avatar
0 votes
2 answers
133 views

Exclude certain disk in dd command script for disk erasure

for disk in $(lspv | awk '{print $1}') ; do dd if=/dev/zero of=/dev/${disk} bs=1024 count=$(bootinfo -s ${disk}) echo $disk wiped done How do i exclude certain disks like hdisk0,hdisk1 and ...
Adel Farhad's user avatar
4 votes
2 answers
5k views

How to identify ancient KornShell version?

We had a guy retire on us, and the documentation left behind is a little on the light side. Need a little help identifying and using part an older client-server system. The server itself is ...
JonathanDavidArndt's user avatar
-2 votes
1 answer
555 views

Execution "df" command on AIX with the bash

it's very strange that when I am executing df command on AIX with bash like  bash -c "df /" I suppose it will be executed like on Linux, but still the result is same like korn shell. Please give me ...
Rovshan Musayev's user avatar
0 votes
1 answer
100 views

Get error "ksh.exe has crashed" when run the command in msys open with admin

When I open msys without admin option on windows server 2008/2012 and run "jbossctl status" command it gives me correct output. But, when I run the same command in msys opened with admin option it ...
shinek's user avatar
  • 121
5 votes
2 answers
5k views

linux + how to identify if file is pointed by link/s

I create new file called - 192.9.200.1 touch 192.9.200.1 then I create new link that will be pointed to 192.9.200.1 file ln -s 192.9.200.1 file so finally I get: ls -ltr /tmp -...
yael's user avatar
  • 2,433
2 votes
2 answers
19k views

sed + how to remove the last string after specific character

how to remove the last string after "." character include the "." character itself implementation can be with sed under Linux/Solaris operation system example of IP address before change 192....
yael's user avatar
  • 2,433
3 votes
2 answers
3k views

rm + how to remove file with special Characters [duplicate]

I have this file in my linux machine: ----------9976723563nneh4_-----192.9.200.4 I try to delete this file but I cant as all see here: what need to add to rm in order to remove this file ? rm "--...
yael's user avatar
  • 2,433
0 votes
2 answers
3k views

linux + delete duplicate IP's from file

what the best way to remove duplicate IP's from file I use the command: sort file | uniq but I am not sure if this is the best way , maybe I missed something? remark: my file contain two ...
yael's user avatar
  • 2,433
1 vote
1 answer
2k views

Linux + exit status from Perl one-liner code

I use Perl one-liners in my ksh scripts. Sometimes it's necessary to get an exit status from the Perl one-liner in order to verify if the Perl one-liner succeeded or not. For example, I need to ...
yael's user avatar
  • 2,433
1 vote
2 answers
1k views

re-create new link and remove the old link on one command

according to ln manual page: man ln -f, --force remove existing destination files so as I understand if I want to re-create new link to some destination directory/file I can ...
Eytan's user avatar
  • 611
2 votes
1 answer
967 views

AIX 7.1 .kshrc ignored

I've created .kshrc file in my home directory, but all my custom settings are ignored. ENV variable is not set. How can I force ksh to read .kshrc? Here is my .kshrc: set -o emacs export PATH=$...
ibykov's user avatar
  • 53
-1 votes
2 answers
1k views

linux/solaris insert date & time at the beginning of each line in file

I want to add date & time at the begging of each line in some file I used sed in order to add the date & time before each line in file please advice what I need to update in my sed in order ...
yael's user avatar
  • 2,433
-2 votes
1 answer
1k views

case + how to implement equal or less or greater in case syntax

my target is to verify the range of number with (only with - case + esac ) , and print the range so for example if number is between 0-80 , case will print >=0<=80 or if range is ...
yael's user avatar
  • 2,433
-3 votes
2 answers
304 views

perl one liners + add empty line after the last line [closed]

please advice what need to change in the perl syntax in order to add new empty line after the last line? example IP_INFO=12.23.2.1 echo IP= | perl -pe "s/$/$IP_INFO/" 1>>file . ...
yael's user avatar
  • 2,433
0 votes
1 answer
626 views

grep to IP address when IP address in parameter

I need to grep to IP address ( as the following example ) , I use ksh script , # ifconfig -a | /usr/xpg4/bin/grep "100\.106\.2\.120 " inet 100.106.2.120 netmask ffffff00 broadcast 100....
yael's user avatar
  • 2,433
1 vote
2 answers
4k views

how to see process status with full details

I run the script - my_script.ksh as process with 5 long arguments on my solaris/linux machine ( example 1 ) , Later I verify the process by ps -ef | grep my_script.ksh I don't understand way ...
yael's user avatar
  • 2,433
178 votes
8 answers
400k views

How do I sleep for a millisecond in bash or ksh

sleep is a very popular command and we can start sleep from 1 second: # wait one second please sleep 1 but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ? ...
yael's user avatar
  • 2,433
-1 votes
2 answers
576 views

shell: create Shortcut command (alias or function) for working with IP address as arguments

I am not sure if I performed the following illegal or true but what I need is - to create set of ready commands so if I need to use , for example to match IP address with 4 octet I can use the ...
yael's user avatar
  • 2,433
-3 votes
1 answer
234 views

linux + count how many digits in IP address [closed]

I write the following syntax (exist in my ksh script) in order to find how many digits I have in IP address IP_address=127.1.1.1 echo $IP_address | sed s'/\./ /g' | wc | awk '{print $2}' 4 . ...
yael's user avatar
  • 2,433
0 votes
3 answers
781 views

grep + Regular Expressions to match uniq number

My target is to verify if $FILE is a backup file ( backup file ended with xxxx.xx.xx.xx number Example of backup files ls /etc/VRTSvcs/conf/config main.cf.17Dec2012.09.10.14 main.cf....
yael's user avatar
  • 2,433
1 vote
1 answer
595 views

Logging commands executed by remote shell scripts

I've noticed that when running a script that connects to a number of our servers (to essentially run batch commands) that the commands aren't logged in the user's .sh_history or .bash_history files. ...
Dan Wolfe's user avatar
-3 votes
2 answers
1k views

linux + solaris + delete all characters in file except numbers and dot char [closed]

please advice how to delete all characters in file except numbers and "." Should be implemented by sed or awk or perl ( one line ) or any other idea , so I will add the syntax in my ksh script ...
yael's user avatar
  • 2,433
2 votes
3 answers
291 views

linux + match only VALID IP from text file into other file

please advice how to match only the valid IPs ( 255.255.255.255 ) from the file.txt and insert only the valid IP into VALID_IP.txt file ( see VALID_IP.txt for example ) the solution should be ...
yael's user avatar
  • 2,433
1 vote
2 answers
225 views

ksh + match and verify two strings in single line

how to match the words linux1a and linux1b from single line ? ( should be performed by ksh ) list="solaris1a Auto global linux1a linux1b" echo $list | .... ? my target is to find that ...
yael's user avatar
  • 2,433
1 vote
1 answer
3k views

expect script + how to perform case in expect script

the following expect script target is to print the hostname name from linux/solaris machine and according to hostname results expect script will run linux.ksh or solaris.ksh script expect_sun_script=`...
yael's user avatar
  • 2,433
0 votes
1 answer
2k views

expect script + write "if" in expect script

please advice what's wrong with my exepct syntax ( I run expect in ksh script on Solaris 10 machine ) I want to verify if OS is linux so if it true the expect check if prompt is "#" or ">" and ...
yael's user avatar
  • 2,433
0 votes
1 answer
99 views

Weird behaviour with ksh?

So I found something somewhat interesting in ksh. I found that if the last character is \, then immediately backspace, the charcter becomes recplaced with ^H. I am then able to press backspace again ...
Chad Harrison's user avatar
-1 votes
1 answer
1k views

linux + print message on the screen after login to linux machine

I have linux machine red-hat 5.1 I want to write ksh/bash script that perform the following Each time that someone login to the linux machine then he will get the following message on the screen - ...
yael's user avatar
  • 2,433
1 vote
0 answers
812 views

Automate an interactive command which use /dev/tty

well pretty much it's in the title. I've a interactive command. This one ask for a password through /dev/tty. I use this command within a shell script. So the command should read the information ...
Daniel's user avatar
  • 121
3 votes
3 answers
8k views

Delete key not working when PuTTYed in to AIX box using Korn shell

I manage an AIX box at work using PuTTY. I'm using ksh in vi-mode. When I press the Delete key (not backspace) the case of following characters is toggled instead of the character under the cursor ...
bshacklett's user avatar
  • 1,378
-1 votes
3 answers
329 views

linux + generate new file with specific structure from text file what the best option

in my Linux machine I have the file orig-file.txt this file include now 4 fields but they could be less or more ( this file generate by other application ) I need advice - what the best option to ...
yael's user avatar
  • 2,433
13 votes
8 answers
8k views

executable in path, findable by which, yet cannot execute without fully qualifying path?

I've got a bizarre seeming shell issue, with a command in the $PATH that the shell (ksh, running on Linux) appears to cowardly refuse to invoke. Without fully qualifying the command, I get: # ...
Peeter Joot's user avatar
5 votes
2 answers
4k views

expect + how to identify if expect break because time out?

The target of the following simple expect script is to get the hostname name on the remote machine Sometimes expect script fail to perform ssh to $IP_ADDRESS ( because remote machine not active , etc ...
Eytan's user avatar
  • 611
1 vote
2 answers
636 views

Script SCP without certificates or expect

I need to script SCP and I need to be able to do this by passing in the password in plain text. I am absolutely aware of the horrible design pattern that I am asking for. I cannot use certificates for ...
wmarbut's user avatar
  • 301
3 votes
1 answer
230 views

shell script (KSH) + set file to param & perform test between param and string

in my linux machine red-hat 5.1 - in ppp file - I have only the signature.pl string !!! remark - third application write the signature.pl string in to ppp file I set ppp file in $a param And ...
Eytan's user avatar
  • 611
0 votes
1 answer
288 views

Lock down Solaris Shell Changing for normal users

I have a few dozen Solaris(5.10) boxes. By default, they are using ksh as the shell. Only a few users have sudo privileges. The rest do not. I don't want my regular users changing to another shell. ...
Publiccert's user avatar
  • 1,112
0 votes
3 answers
105 views

shell script + match MAJOR and CRITICAL strings from log file

I need to match lines that have MAJOR and CRITICAL strings that comes after the word ERROR:< any integer number > please advice how to do that with one awk or sed command? more HW_Log.txt ...
Eytan's user avatar
  • 611
0 votes
1 answer
243 views

ksh + print the last value from parameter ( as $_ in perl)

I need advice - how to print the same last value in ksh scripts without to print param argument for example in perl last value is $_ , but we not have this option in ksh script example - of ksh ...
Eytan's user avatar
  • 611
0 votes
2 answers
2k views

svn: Too many arguments to import command

Having a problem with the --message flag to the svn import command. On some servers it works, but on others it gets confused if the message contains spaces, even if you single or double quote the ...
RCross's user avatar
  • 469
0 votes
1 answer
1k views

linux + run script on other shell because script stuck - not return to linux prompt

In my Linux machine I have binary script (called transferNames.bin ) The problem is that when I run transferNames.bin with & script stuck and not returns to Linux prompt “#”, even if I wait 1 day ...
Eytan's user avatar
  • 611
2 votes
4 answers
14k views

linux + create simple watch dog process in shell script

I need to create watch dog process (will run in linux version 5.x) that look all time on /etc/cluster.cf file And if the process matches the string: machineA_is_active in the cluster.cf file Then ...
Eytan's user avatar
  • 611
1 vote
2 answers
261 views

Solaris 8 - directories gone missing; is this housecleaning script the culprit?

Our 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 ...
Dave's user avatar
  • 11
1 vote
1 answer
134 views

shell script + add inside the script PATH for standard output

Usually if we want to redirect script output to file we simply do /etc/create_connection.sh > file.debug.txt Or /etc/create_connection.sh | tee –a file.debug.txt But What I want is ...
Eytan's user avatar
  • 611
1 vote
1 answer
2k views

What version of ksh ships with AIX 5.3?

I'm writing a Korn shell script for a client, who will use it on AIX 5.3. For testing, I'm using version 93u-1 Debian Wheezy. Is this the same version as the one I'll find on AIX?
Martin Geisler's user avatar
2 votes
2 answers
182 views

What do the 2 leading underscores indicate in these alias lines for .kshrc?

I am configuring ksh88 on AIX 5.3L and came across a few lines that are supposed to enable the arrow keys for command history navigation. alias __A=$(print -n "\020") alias __B=$(print -n "\016") ...
Buggabill's user avatar
  • 179
3 votes
2 answers
2k views

Preventing bash (and ksh) history alteration in Linux

From the looks of things, fixing ksh to make history alteration impossible is fairly easy. I've seen all the recommendations to make HIST* environment variables read-only, and the use of chattr to ...
Mei's user avatar
  • 4,590
1 vote
2 answers
97 views

ksh93 esc-esc complation

Does anyone know how to set esc-esc completion? I've installed ksh93 from ports on FreeBSD. set -o vi NOR set -o viraw have any effect Thanks
Xman's user avatar
  • 11
2 votes
2 answers
1k views

ctrl-v key on AIX

I'm new to AIX and I miss some tricks that work well on other *nix flavors. I need a CTRL sequence in a ksh scripts, like ^[ (CTRL-[) and to do that I'm habit to use the ctrl-v [ , but here it doesn'...
tmow's user avatar
  • 1,227