Return the position of matched string from right, awk match can do from left only.
e.g return pos 7 for search string "service" from "AA-service"
or return the matched string "service", then caculate the string length.
Thanks!. (3 Replies)
I have a shell script which I made with the help of this forum
#!/bin/sh
RuleNum=$1
cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}'
Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
Hi,
when i grep for the process "XYZ" , there will be some good number of processes with that name, i want to kill all the these processes at a time using shell script?
Any help needed for this action.
Thanks
Regards,
Anil (6 Replies)
Pls. advise how to find or used grep recursively all shell script files.
Some files doesnt have a .sh or .ksh extension name.
find / -name "*" |xargs grep bin |grep sh
??
TIA (1 Reply)
Hi,
i am not able to run the loop in nohup directly.
nohup 'for i in $(seq 10); do echo $i;./mscript.sh $i; done'
can some one help me how to run this directly in nohup?
---------- Post updated 03-15-12 at 12:20 AM ---------- Previous update was 03-14-12 at 11:59 PM ----------
From... (0 Replies)
Hi fellas,
I have a file that contains text something like this
SNAPSHOT snap-021ede4a vol-bc3f89c0 completed 2012-11-19T06:05:26+0000 100% 170495546006 850 Created by CreateImage(i-6adc0515) for ami-977dfafe from vol-bc3f89c0
TAG snapshot snap-021ede4a project PAC
TAG snapshot... (5 Replies)
I am trying to use an awk command within a ksh script but it is not working - I am able to run from command line with no problem. It does not err out - it just does not produce a file with final count.
awk "{s+=$0} END {print s}" es.out > es.cntAny help would be greatly appreciated. Thanks (6 Replies)
Hi
Iam running below script in crontab but its not working.
#!/bin/sh
cd /Scripts
/usr/local/bin/expect -f /Scripts/bng_backup.exp /Scripts/data.txt
tar -cf bngbackup.tar bngbackup ;gzip bngbackup.tar
when iam running manually the output file is generating..but bngbackup.tar.gz file... (5 Replies)
Hi,
i have one simple PL/SQL Block and i have saved it as .sql file, which i am trying to call from UNIX script.
PL/SQL block structure
CONNECT DB_NAME/PWD@Database
whenever SQLERROR EXIT 1;
Declare
..Variables...
BEGIN
--Code--
exception
END;
exit;
I have save this block as... (3 Replies)
Hi,
I do have an R script named KO.R. Basically reads thousands of files, whose name has a pattern that differs at a portion of the file name, List.txt.
Row_file1_mile.txt
Row_file2_mile.txt
Row_file3_mile.txt
...
...
Row_file1000_mile.txt
Below is a portion of my Rscript that reads... (4 Replies)
Discussion started by: Kanja
4 Replies
LEARN ABOUT PHP
mysqli_set_local_infile_handler
MYSQLI_SET_LOCAL_INFILE_HANDLER(3) 1 MYSQLI_SET_LOCAL_INFILE_HANDLER(3)mysqli::set_local_infile_handler - Set callback function for LOAD DATA LOCAL INFILE command
Object oriented style
SYNOPSIS
bool mysqli::set_local_infile_handler (mysqli $link, callable $read_func)
DESCRIPTION
Procedural style
bool mysqli_set_local_infile_handler (mysqli $link, callable $read_func)
Set callback function for LOAD DATA LOCAL INFILE command
The callbacks task is to read input from the file specified in the LOAD DATA LOCAL INFILE and to reformat it into the format understood by
LOAD DATA INFILE.
The returned data needs to match the format specified in the LOAD DATA
PARAMETERS
o $
link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3)
o $read_func
- A callback function or object method taking the following parameters:
o $stream
-A PHP stream associated with the SQL commands INFILE
o $&buffer
-A string buffer to store the rewritten input into
o $buflen
-The maximum number of characters to be stored in the buffer
o $&errormsg
-If an error occurs you can store an error message in here
The callback function should return the number of characters stored in the $buffer or a negative value if an error occurred.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
mysqli::set_local_infile_handler example
Object oriented style
<?php
$db = mysqli_init();
$db->real_connect("localhost","root","","test");
function callme($stream, &$buffer, $buflen, &$errmsg)
{
$buffer = fgets($stream);
echo $buffer;
// convert to upper case and replace "," delimiter with [TAB]
$buffer = strtoupper(str_replace(",", " ", $buffer));
return strlen($buffer);
}
echo "Input:
";
$db->set_local_infile_handler("callme");
$db->query("LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1");
$db->set_local_infile_default();
$res = $db->query("SELECT * FROM t1");
echo "
Result:
";
while ($row = $res->fetch_assoc()) {
echo join(",", $row)."
";
}
?>
Procedural style
<?php
$db = mysqli_init();
mysqli_real_connect($db, "localhost","root","","test");
function callme($stream, &$buffer, $buflen, &$errmsg)
{
$buffer = fgets($stream);
echo $buffer;
// convert to upper case and replace "," delimiter with [TAB]
$buffer = strtoupper(str_replace(",", " ", $buffer));
return strlen($buffer);
}
echo "Input:
";
mysqli_set_local_infile_handler($db, "callme");
mysqli_query($db, "LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1");
mysqli_set_local_infile_default($db);
$res = mysqli_query($db, "SELECT * FROM t1");
echo "
Result:
";
while ($row = mysqli_fetch_assoc($res)) {
echo join(",", $row)."
";
}
?>
The above examples will output:
Input:
23,foo
42,bar
Output:
23,FOO
42,BAR
SEE ALSO mysqli_set_local_infile_default(3).
PHP Documentation Group MYSQLI_SET_LOCAL_INFILE_HANDLER(3)