ksh

how to escape unusual/uniq characters from expect scripts?

心已入冬 提交于 2021-02-16 20:14:28
问题 in expect script I can set any command or character to run it on remote machine but the sad thing is that expect cant send the same character as they defined in the expect script for example I want to run this line from expect script in order to change IP address from 10.10.10.10 to 1.1.1.1 expect # {send "perl -i -pe 's/\Q10.10.10.10\E/1.1.1.1/' /etc/hosts\r"} but when I run the expect screen actually I see this line runing on the console: [root@localhost ~]# perl -i -pe 's/Q10.10.10.10E/1.1

Run awk comand on a remote server through ssh

血红的双手。 提交于 2021-02-05 11:46:45
问题 I'm trying to get a specific set of values from a file on a remote server. The command works fine when executing that through terminal. First ssh Command sshpass -p password ssh -T user@ip Second Awk Command find /opt/Info_Source/*daily* -type f -mtime -1 -exec zcat {} \; 2>/dev/null | awk -F, -v OFS=',' '$5 ~ /Valid/ && length($2) {print $2}' but if I combine both of them in a script #!/bin/ksh emp_id=`sshpass -p password ssh -T user@ip -q << EOF find /opt/Info_Source/*daily* -type f -mtime

Elegant use of arrays in ksh

妖精的绣舞 提交于 2021-01-28 12:11:08
问题 I'm trying build an sort of property set in ksh. Thought the easiest way to do so was using arrays but the syntax is killing me. What I want is to Build an arbitrary sized array in a config file with a name and a property. Iterate for each item in that list and get that property. I theory what I wish I could do is something like MONITORINGSYS={ SYS1={NAME="GENERATOR" MONITORFUNC="getGeneratorStatus"} SYS2={NAME="COOLER" MONITORFUNC="getCoolerStatus"} } Then later on, be able to do something

Unix cp argument list too long

倾然丶 夕夏残阳落幕 提交于 2020-05-12 11:43:09
问题 I am using AIX. When I try to copy all the file in a folder to another folder with the following command: cp ./00012524/*.PDF ./dummy01 The shell complains: ksh: /usr/bin/cp: 0403-027 The parameter list is too long. How to deal with it? My folder contain 8xxxx files, how can I copy them very fast? each file have size of 4x kb to 1xx kb. 回答1: Use find command in *nix: find ./00012524 -type f -name "*.PDF" -exec cp {} ./dummy01/ \; -print 回答2: The cp command has a limitation of files which you

How to put environment variable in Array?

南楼画角 提交于 2020-04-18 06:10:13
问题 DIR1, DIR2, .... DIRN are coming from environment variables that contains some directory path. example export DIR1="/users/abcd" export DIR2="/users/abcd/xyz" . . . How do i know that how many DIR_ is in environment variable and put all these in the following array arr=(DIR1 DIR2 ... . . DIRN) i=0 while [ $i -lt ${#arr[@]} ] do cd ${arr[$i]} i=`expr $i + 1` done 回答1: For the cases when environment variables may contain newlines in their values you can use this script that uses gnu versions of

How to put environment variable in Array?

梦想与她 提交于 2020-04-18 06:10:08
问题 DIR1, DIR2, .... DIRN are coming from environment variables that contains some directory path. example export DIR1="/users/abcd" export DIR2="/users/abcd/xyz" . . . How do i know that how many DIR_ is in environment variable and put all these in the following array arr=(DIR1 DIR2 ... . . DIRN) i=0 while [ $i -lt ${#arr[@]} ] do cd ${arr[$i]} i=`expr $i + 1` done 回答1: For the cases when environment variables may contain newlines in their values you can use this script that uses gnu versions of

SQL*Plus script executed twice

吃可爱长大的小学妹 提交于 2020-04-16 03:21:07
问题 I'm trying to run a script using sqlplus. My script is a simple delete statement. I execute it by putting the following in my ksh terminal: sqlplus username/'password' @../sql/delete_societes.sql ../sql/delete_societes.sql is DELETE FROM f2020.SOCIETES; / For some reason, it runs twice, causing the output "0 lines deteleted" to be printed twice and causing errors when I try to do an insert instead of a delete. 回答1: Make your script do either; DELETE FROM f2020.SOCIETES / or DELETE FROM f2020

SQL*Plus script executed twice

烈酒焚心 提交于 2020-04-16 03:17:08
问题 I'm trying to run a script using sqlplus. My script is a simple delete statement. I execute it by putting the following in my ksh terminal: sqlplus username/'password' @../sql/delete_societes.sql ../sql/delete_societes.sql is DELETE FROM f2020.SOCIETES; / For some reason, it runs twice, causing the output "0 lines deteleted" to be printed twice and causing errors when I try to do an insert instead of a delete. 回答1: Make your script do either; DELETE FROM f2020.SOCIETES / or DELETE FROM f2020