I have having problems with an IF statement in my perl script:
What i am trying to accomplish is if the model is set to "N\A" and the kernel variable has xen somewhere in it i would like to change the variable to "virtual machine". Otherwise just leave it alone. The rest of my script works great this is the last part. The code above does not do what i want it to, it turns every model into a virtual machine regardless if it is set or not.
Can someone explain the difference between backticks and system when
evaluated in these if statements:
sub getDate {
print "start date\n";
if ( system("/bin/date") ) {
print "can't get date\n";
exit(2);
}
print "finish date\n";
}
Returns the following:
start date
Thu... (5 Replies)
Sorry to be a pain, but how does the else work in the if statements?
Ive been making scripts with if statements but i cant get the else statements working.
Can you help? (8 Replies)
Hi All,
Must be something obvious I am missing, but the simple script below doesn't work.
#!/bin/sh
x=4
if
then
echo "x is $x"
elsif
then
echo "x is greater than 4"
else
echo "x is less than 4"
fi
When I run this script, I get the error message:
7: Syntax error... (3 Replies)
This is for a program I have to do to calculate the day of the week.
I need to write an if statement that will do the following:
if day is 29 and year is odd, don't calculate dayif ( day == 29 && year == ??? )I know how to do it for the day but I don't know how to do it for the year. (4 Replies)
So far, all I have been able to come up with is:
if ($check=~/no/ || $check=~/n/)
but the problem with this, is that it looks for any character and the if statement is true. So if I wanted to check for an argument "-help" or lets say a variable string that could be a file name. Then... (2 Replies)
Hi guys,
Two problems I need solving please. I created a script where the user types in 7 numbers as standard input and each one is then stored in an array. Now I need to perform the following calculations on those numbers:
1) Use a while loop to determine the largest number in the range.
... (2 Replies)
Hello. I am new here and new to scripting. I used to have a very basic script that worked for simple backup/restore of files. I have expanded it and well... I have ended up with a complete mess. It still backs up and restores but there is so many issues that stem from the many if statements I... (3 Replies)
I have a file like
file.
file.TODAY.THISYEAR
file.TODAY.LASTYEARI want to substitute the words in caps with their actual values so that output should look like
file.140805
file.140805.2014
file.140805.2013For this I am reading the file line bye line in an array and using multiple map... (1 Reply)
have issue where my elsif is always failing. Basically i have a file with sets of 2 lines, the 1st line that containing "ipwr" and the 2nd line containing a value or "unknown". if the 2nd line contains a value then i want to print the pair of lines.
open (INFO, "temp.txt") or die;
... (3 Replies)