07-31-2012
It's the double ;; under 1 case.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to run the script bellow but its given me "syntax error at line 20 :'done' unexpected." error message"
can someone check to see if the script is ok? and correct me pls.
Today is my first day with scripting.
Gurus should pls help out
#!/bin/ksh
# Purpose: Check to see if file... (3 Replies)
Discussion started by: ibroxy
3 Replies
2. Solaris
one of my script as follows
HOME=/apps/logs
mv $HOME/cron.log $HOME/cron.log.`date +%Y-%m-%d`
touch $HOME/cron.log
fi
i am getting error as follows
on the last line we are getting ...
"syntax error near unexpected token `fi' "
please suggest.... (4 Replies)
Discussion started by: GIC1986
4 Replies
3. Shell Programming and Scripting
I have a very simple script that reads in the contents of a file (_open.txt) into an array "lyrics":
#!/bin/sh
# read in the text
lyrics=( `cat _open.txt` | tr '\n' ' ')
exit 0
It gives the following error message:
./lyrics.sh: 1: Syntax error: word unexpected (expecting ")")
I have... (9 Replies)
Discussion started by: figaro
9 Replies
4. UNIX for Dummies Questions & Answers
im kinda new to shell scripting so i need some help
i try to run this script and get the error code
> 5 ")syntax error: operand expected (error token is "
the code for the script is
#!/bin/sh
#
# script to see if the given value is correct
#
# Define errors
ER_AF=86 # Var is... (4 Replies)
Discussion started by: metal005
4 Replies
5. Shell Programming and Scripting
Hello forum,
I hope my problem is easy to solve for someone in here!
My main task is to copy a large amount of imap-accounts from one server to another. There is a tool (Perl) called imapsync which does the job exellent. Unfortunately I'm only able to run it on one account at a time.
After... (3 Replies)
Discussion started by: primaxx
3 Replies
6. Shell Programming and Scripting
Hi Techies,
can anyone please debug the following Script and let me know what is going wrong here.
im getting the following error
#!/usr/bin/bash
# ##############################################################################################
#
# Variables
#
#... (2 Replies)
Discussion started by: mahi_mayu069
2 Replies
7. Shell Programming and Scripting
Hi All,
Please hav a look at the below peice of script and let me know if there are any syntax errors.
i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies
8. Shell Programming and Scripting
While i m running below code, it is giving me the error"syntax error at line 15: `end of file' unexpected".
Pls let me know what is wrong here..i tried many ways, but no luck
dbSID="SWQE"
usrname="apps"
password="Wrgthrk3"
count=0
while
do
sqlplus $usrname/$password@$dbSID... (5 Replies)
Discussion started by: millan
5 Replies
9. BSD
#!/bin/bash
#--------------------------------------------------------
# Setup prompt
# Author Zeeshan Mirza
# Data: 06-08-2017
#--------------------------------------------------------
if
then
. ./.profile_custom_pre
fi
umask 022
set -o vi
export EDITOR=vi
export VISUAL=vi... (3 Replies)
Discussion started by: getzeeshan
3 Replies
10. Shell Programming and Scripting
Hello all,
I am running a script to generate a report and mail it to an email address.
When I am trying to validate whether the file is a 0 kb file, I am getting the below error.
Error: "Syntax error; unexpected end of file"
Any suggestions please?
Code:
#!/bin/sh
.... (1 Reply)
Discussion started by: Pradeep_Raj
1 Replies
LEARN ABOUT PHP
preg_replace_callback
PREG_REPLACE_CALLBACK(3) 1 PREG_REPLACE_CALLBACK(3)
preg_replace_callback - Perform a regular expression search and replace using a callback
SYNOPSIS
mixed preg_replace_callback (mixed $pattern, callable $callback, mixed $subject, [int $limit = -1], [int &$count])
DESCRIPTION
The behavior of this function is almost identical to preg_replace(3), except for the fact that instead of $replacement parameter, one
should specify a $callback.
PARAMETERS
o $pattern
- The pattern to search for. It can be either a string or an array with strings.
o $callback
- A callback that will be called and passed an array of matched elements in the $subject string. The callback should return the
replacement string. This is the callback signature:
string handler (array $matches) You'll often need the $callback function for a preg_replace_callback(3) in just one place. In
this case you can use an anonymous function to declare the callback within the call to preg_replace_callback(3). By doing it this
way you have all information for the call in one place and do not clutter the function namespace with a callback function's name
not used anywhere else.
Example #1
preg_replace_callback(3) and anonymous function
<?php
/* a unix-style command line filter to convert uppercase
* letters at the beginning of paragraphs to lowercase */
$fp = fopen("php://stdin", "r") or die("can't read stdin");
while (!feof($fp)) {
$line = fgets($fp);
$line = preg_replace_callback(
'|<p>s*w|',
function ($matches) {
return strtolower($matches[0]);
},
$line
);
echo $line;
}
fclose($fp);
?>
o $subject
- The string or an array with strings to search and replace.
o $limit
- The maximum possible replacements for each pattern in each $subject string. Defaults to -1 (no limit).
o $count
- If specified, this variable will be filled with the number of replacements done.
RETURN VALUES
preg_replace_callback(3) returns an array if the $subject parameter is an array, or a string otherwise. On errors the return value is NULL
If matches are found, the new subject will be returned, otherwise $subject will be returned unchanged.
CHANGELOG
+--------+---------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------+
| 5.1.0 | |
| | |
| | The $count parameter was added |
| | |
+--------+---------------------------------+
EXAMPLES
Example #2
preg_replace_callback(3) example
<?php
// this text was used in 2002
// we want to get this up to date for 2003
$text = "April fools day is 04/01/2002
";
$text.= "Last christmas was 12/24/2001
";
// the callback function
function next_year($matches)
{
// as usual: $matches[0] is the complete match
// $matches[1] the match for the first subpattern
// enclosed in '(...)' and so on
return $matches[1].($matches[2]+1);
}
echo preg_replace_callback(
"|(d{2}/d{2}/)(d{4})|",
"next_year",
$text);
?>
The above example will output:
April fools day is 04/01/2003
Last christmas was 12/24/2002
Example #3
preg_replace_callback(3) using recursive structure to handle encapsulated BB code
<?php
$input = "plain [indent] deep [indent] deeper [/indent] deep [/indent] plain";
function parseTagsRecursive($input)
{
$regex = '#[indent]((?:[^[]|[(?!/?indent])|(?R))+)[/indent]#';
if (is_array($input)) {
$input = '<div style="margin-left: 10px">'.$input[1].'</div>';
}
return preg_replace_callback($regex, 'parseTagsRecursive', $input);
}
$output = parseTagsRecursive($input);
echo $output;
?>
SEE ALSO
PCRE Patterns, preg_quote(3), preg_replace(3), preg_last_error(3), Anonymous functions, information about the callback type.
PHP Documentation Group PREG_REPLACE_CALLBACK(3)