08-14-2013
Try the deprecated and dangerous eval!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I am an intermediate scripter. I can usually find and adapt what I need by searching through previous postings, but I'm stumped.
I have a string with the format "{Name1 Release1 Type1 Parent1} {Name2 Release2 Type2 Parent2}". It is being passed as an argument into a ksh script. I need to... (5 Replies)
Discussion started by: drd_2b
5 Replies
2. UNIX for Dummies Questions & Answers
search=Jul 22
date=Jul 22
if
then
echo They match
>>this piece of code does not detect that search and date are equivalent strings.. what's wrong with it? (17 Replies)
Discussion started by: katdaniel16
17 Replies
3. Shell Programming and Scripting
HI all,
Very new to shell programming and just wanted some help on how to solve the following problem.
I have a small shell script which searches a given file and extracts some string parameters. I want to now be able to call this script from another shell script and somehow pass the parameters... (11 Replies)
Discussion started by: pxy2d1
11 Replies
4. Shell Programming and Scripting
Is there any way to compare two strings for a greater or less than condition? For example, StringA is "apple" and StringB is "bonnet" and StringC is "captain". Can I only test for equal/not-equal, or is there a way to find out whether StringA is less than StringB, and StringC is greater than... (6 Replies)
Discussion started by: OPTIMUS_prime
6 Replies
5. Shell Programming and Scripting
I have two variables and want to perform some functions after comparison
$cat file1
14.abcde
a=`cut -f 1 -d "." file1
b=15
if
then
....
fi
but i got an error message says that unary operator expected
and i think its because of $a is a string and trying to compare with... (3 Replies)
Discussion started by: bonosungho
3 Replies
6. Shell Programming and Scripting
i have
/tmp/dev/string1/testfile.txt
i need only testfile.txt
How can get that..can anyone helpme out
Thanx (2 Replies)
Discussion started by: KiranKumarKarre
2 Replies
7. Shell Programming and Scripting
I'm working in korn shell and have a variable which contains a string like:
aa_yyyymmdd_bbb_ccc_ddd.abc. I want to treat the _ and . as delimiters and parse the string so I end up with 6 values in variables that I can manipulate. My original plan was to use
var1=`echo $sting1 | cut -c1-c2` but... (9 Replies)
Discussion started by: aquimby
9 Replies
8. Shell Programming and Scripting
Hi,
i am new to Shell Scripting, i want to get some input from user which is string, and i want to store it into variables.
Eg:
str='hello how are you'
i want to store this string into 4variables
lyk s1=hello
s2=how
s3=are
s4=you
thanks,
lak (11 Replies)
Discussion started by: lakshmikanthe
11 Replies
9. Shell Programming and Scripting
Hi guys,
I'm using tcsh.
I have a string that contains variable names: "var1:var2:var 3", I want to be able to do different operations on the content of those variables:
I extract the variable names with: foreach var ( `echo $string | sed 's/:/\n/g'`)
now in the variable `var` I have the... (1 Reply)
Discussion started by: gofmarat
1 Replies
10. Shell Programming and Scripting
I have a file
$ cat myfile
A 02/16/2012
B 02/19/2012
C 02/20/2012
D 02/17/2012
E 02/16/2012
My simple script
> cat myscript.sh
mydate="02/16/2012"
awk ' ($2~/$mydate/) {print $1}' < myfile
but I got no output! and when I try $2~/'$mydate'/
I got: The error context is (2 Replies)
Discussion started by: Sara_84
2 Replies
ERR(3) Library Functions Manual ERR(3)
NAME
err, verr , errx , verrx , warn , vwarn , warnx , vwarnx - formatted error messages
SYNOPSIS
void
err(eval, fmt, ...)
int eval;
char *fmt;
void
verr(eval, fmt, args)
int eval;
char *fmt;
va_list args;
void
errx(eval, fmt, ...)
int eval;
char *fmt;
void
verrx(eval, fmt, args)
int eval
char *fmt;
va_list args;
void
warn(fmt, ...)
char *fmt;
void
vwarn(fmt, args)
char *fmt;
va_list args;
void
warnx(fmt, ...)
char *fmt;
void
vwarnx(fmt, args)
char *fmt;
va_list args;
DESCRIPTION
The err and warn family of functions display a formatted error message on the standard error output. In all cases, the last component of
the program name, a colon character, and a space are output. If the fmt argument is not NULL, the formatted error message, a colon charac-
ter, and a space are output. In the case of the err, verr, warn, and vwarn functions, the error message string affiliated with the current
value of the global variable errno is output. In all cases, the output is followed by a newline character.
The err, verr, errx, and verrx functions do not return, but exit with the value of the argument eval.
EXAMPLES
Display the current errno information string and exit:
if ((p = malloc(size)) == NULL)
err(1, NULL);
if ((fd = open(file_name, O_RDONLY, 0)) == -1)
err(1, "%s", file_name);
Display an error message and exit:
if (tm.tm_hour < START_TIME)
errx(1, "too early, wait until %s", start_time_string);
Warn of an error:
if ((fd = open(raw_device, O_RDONLY, 0)) == -1)
warnx("%s: %s: trying the block device",
raw_device, strerror(errno));
if ((fd = open(block_device, O_RDONLY, 0)) == -1)
err(1, "%s", block_device);
SEE ALSO
strerror(3)
HISTORY
The err and warn functions first appeared in 4.4BSD.
4th Berkeley Distribution February 3, 1995 ERR(3)