I have created one function for KSH and was running well with one parameter input since I just had to use $1 to get the parameter.
Now I want to do loop for each parameter(actually filenames) . I have try to use do loop, but $i does not resolve to parameter instead it resolves to 1, 2, 3 etc...
example,
Code:
func()
echo There are ${#} parameters..
i=1
while (( i <= ${#} ))
do
if [ ! -f $("$i")];
then
echo "Error $i does not exist!"
else
echo "Error $i does exist, please proceed".
fi
(( i+=1 ))
done
}
HI all
I have a code like
##############################################
minyear()
{
curryear=$1
echo $curryear
}
##Main Program ##
minyear
exit
#######
when i execute "sh scriptname 2005" output should be like 2005 but the output is blank.
I guess i need to pass parameter to... (3 Replies)
Hello,
Can anyone guide me tin passing parameters into user defined function of shell script (KSH).
Here is my code,
InsertRecord()
{
DB_TBL=$(sqlplus $USERID/$PASSWORD@$DATABASE << EOF
set head off
set feed off
set serveroutput on
INSERT INTO TBL1 ( OLD_VAL,
NEW_VAL,
... (7 Replies)
Hi guys,
can someome help with this question, I have defined a function that takes a command as a parameter, but when the command is executed from the function it will throw errors because what I believe is a special character escaping issue. I tried using the backslash to escape the pipe | and >... (2 Replies)
Hello again :)
Am currently trying to write a function which will delete a record from a file.
The code currently looks as such:
function deleteRecord() {
clear
read -p "Please enter the ID of the record you wish to remove: " strID
... (2 Replies)
I want to pass this array as a parameter.
IFS=$'\n'
fortune_lines=($(fortune | fold -w 30 ))
Inside of this line
screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${fortune_lines}\r"`"
And I am lost at this point.
I am thinking something like this?
Then make it loop..
... (7 Replies)
Hi,
I have following for loop , please let me know how to get ${TXP_EXT_TABLE_${i}_SQL} parameter with 1DAY and 7DAY values.
for i in 1DAY 7DAY
do
${NZSQL_DIR}/nzsql -h ${HOST} -time -v ON_ERROR_STOP=1 -f ${SQL_DIR}/${TXP_EXT_TABLE_${i}_SQL} > ${TMP_LOG_FILE} 2>&1
done
... (4 Replies)
Hi Gurus,
I have request which needs to pass position parameter to a function. I tried below simple code, it doesn't work.
#!/bin/bash
func_1(){
echo $1
}
func_1
$ ./set_file abc
$
do I need add some to get the position para first?
thanks in advance. (3 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
2. Relevant commands, code, scripts, algorithms:
#! /bin/ksh
v="ORG_ID"
... (2 Replies)
Discussion started by: sujitdas2104
2 Replies
LEARN ABOUT REDHAT
bdflush
BDFLUSH(2) Linux Programmer's Manual BDFLUSH(2)NAME
bdflush - start, flush, or tune buffer-dirty-flush daemon
SYNOPSIS
int bdflush(int func, long *address);
int bdflush(int func, long data);
DESCRIPTION
bdflush starts, flushes, or tunes the buffer-dirty-flush daemon. Only the super-user may call bdflush.
If func is negative or 0, and no daemon has been started, then bdflush enters the daemon code and never returns.
If func is 1, some dirty buffers are written to disk.
If func is 2 or more and is even (low bit is 0), then address is the address of a long word, and the tuning parameter numbered (func-2)/2
is returned to the caller in that address.
If func is 3 or more and is odd (low bit is 1), then data is a long word, and the kernel sets tuning parameter numbered (func-3)/2 to that
value.
The set of parameters, their values, and their legal ranges are defined in the kernel source file fs/buffer.c.
RETURN VALUE
If func is negative or 0 and the daemon successfully starts, bdflush never returns. Otherwise, the return value is 0 on success and -1 on
failure, with errno set to indicate the error.
ERRORS
EPERM Caller is not super-user.
EFAULT address points outside your accessible address space.
EBUSY An attempt was made to enter the daemon code after another process has already entered.
EINVAL An attempt was made to read or write an invalid parameter number, or to write an invalid value to a parameter.
CONFORMING TO
bdflush is Linux specific and should not be used in programs intended to be portable.
SEE ALSO fsync(2), sync(2), update(8), sync(8)Linux 1.2.4 1995-04-15 BDFLUSH(2)