ksh

Shell script templates [closed]

你说的曾经没有我的故事 提交于 2019-11-28 15:49:22
What would be your suggestions for a good bash/ksh script template to use as a standard for all newly created scripts? I usually start (after the #! line) with a commented-out header with a filename, synopsis, usage, return values, author(s), changelog and would fit into 80-char lines. All documentation lines I start with double-hash symbols ## so I can grep for them easily and local var names are prepended with "__". Any other best practices? Tips? Naming conventions? What about return codes? Comments on version control : we use SVN all right, but another dept in the enterprise has a separate

compare contents of two directories on remote server using unix

 ̄綄美尐妖づ 提交于 2019-11-28 15:44:47
I am new to unix and need some help here. I have two directories present on two different server. both the directories contains the same files. Now i want to check if all files are in sync in both the directories. If files are not in sync then i want to display only name of those files. I am able to do it when directories are on same server. not able to figure out how to do this when directories are present on two different servers. eg: server1 /abc/home/sample1/ server2 /abc/home/sample2/ here i want only files name to display when it not in sync. Thanks in advance kielni You can use rsync

Shell script templates [closed]

十年热恋 提交于 2019-11-28 14:57:37
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . What would be your suggestions for a good bash/ksh script template to use as a standard for all newly created scripts? I usually start (after the #! line) with a commented-out header with a filename, synopsis, usage, return values, author(s), changelog and would fit into 80-char

Getting past dates in HP-UX with ksh

半腔热情 提交于 2019-11-28 12:29:08
问题 Ok, so I need to translate a script from a nice linux & bash configuration to ksh in hp-ux. Each and every command expects a different syntax and i want to kill myself. But let's skip the rant. This is part of my script anterior=`date +"%Y%0m" -d '1 month ago'` I basically need to get a past date in format 201002. Never mind the thing that, in the new environment, %0m means "no zeroes", while actually in the other one it means "yes, please put that zero on my string". It doesn't even accept

Pass variable from a child to parent in KSH

你。 提交于 2019-11-28 11:50:49
问题 I have to work with KSH (yeah that hell shell). I need to use a fork, a subroutine as following: #!/bin/ksh PIPE=PIPE_$$ PIPE_ERR=PIPE_ERR_$$ export TEST_FILS $(. ./LanceFils.ksh 2>${PIPE_ERR} 1>${PIPE}) & PID_CHILD=$! echo "Nom du fichier PIPE: ${PIPE}" echo "Processus fils : " $! wait ${PID_CHILD} echo "Code retour: " $? echo "Sortie standard de PROC_FILS : " $(cat ${PIPE}) echo "Sortie d'erreur(s) de PROC_FILS : " $(cat ${PIPE_ERR}) echo "Contenu de TEST_FILS: ${TEST_FILS}" rm -rf ${PIPE}

How do I capture a SQLPlus exit code within a shell script?

做~自己de王妃 提交于 2019-11-28 10:13:07
I have a KornShell (ksh) script that logins into SQL*Plus and executing a script. Within the shell script I would like to capture the status code of the SQL statement that was executed. Currently there is an error with SQL and I am unable to capture it by checking $?. How would I capture the success or error code from the sql statement and pass it to the shell script. Snippet of ksh script: sqlplus $JDBC_FBUID_U/$JDBC_FBPWD_U@$JDBC_FBDB @${FBC_HOME}/FBCS003.sql ${outputfile} if [ $? != 0 ] then msg_txt="The execution of Sql script /tmp/FBCS003.sql failed. Please investigate." echo ${msg_txt}

ksh88 changing single quotes to double quotes inside heredocs?

房东的猫 提交于 2019-11-28 10:09:05
I seem to be running into an issue that's specific to ksh88 that's changing single quotes to double quotes, but only under certain situations involving heredocs and command substitution. Here's an example: #!/bin/ksh # This example works correctly echo "Example 1:" cat <<EOF The 'quick' brown fox "jumped" over the lazy dog. EOF echo # This example is broken echo "Example 2:" var=$(cat <<EOF The 'quick' brown fox "jumped" over the lazy dog. EOF) echo "${var}" echo # This example works correctly echo "Example 3:" var=`cat <<EOF The 'quick' brown fox "jumped" over the lazy dog. EOF` echo "${var}"

Reading file line by line (with space) in Unix Shell scripting - Issue

老子叫甜甜 提交于 2019-11-28 06:26:24
I want to read a file line by line in Unix shell scripting. Line can contain leading and trailing spaces and i want to read those spaces also in the line. I tried with "while read line" but read command is removing space characters from line :( Example if line in file are:- abcd efghijk abcdefg hijk line should be read as:- 1) "abcd efghijk" 2) " abcdefg hijk" What I tried is this (which not worked):- while read line do echo $line done < file.txt I want line including space and tab characters in it. Please suggest a way. sat Try this, IFS='' while read line do echo $line done < file.txt EDIT:

What is the maximum number of characters that the ksh variable accepts?

纵然是瞬间 提交于 2019-11-28 05:29:17
问题 I am trying to load and parse a really large text file. Although the loading is not a problem, but there are particular lines that have 2908778 characters on a single line. This is causing an error in my script. On the script below, I removed all logic and just got straight to read line. I also removed all valid lines and just left the really long line in one text file. When running I get the below error : $ dowhiledebug.sh dump.txt dowhiledebug.sh[6]: no space Script Ended dump.txt The

File execution with dot space versus dot slash

…衆ロ難τιáo~ 提交于 2019-11-28 05:03:11
I am attempting to work with an existing library of code but have encountered an issue. In short, I execute a shell script (let's call this one A ) whose first act is to call another script ( B ). Script B is in my current directory (a requirement of the program I'm using). The software's manual makes reference to bash , however comments in A suggest it was developed in ksh . I've been operating in bash so far. Inside A , the line to execute B is simply: . B It uses the "dot space" syntax to call the program. It doesn't do anything unusual like sudo . When I call A without dot space syntax, i