Rohit Bajaj
asked on
check failing on yum update
HI,
I am using the below code in my post deploy script :
As per my understanding when yum update rpm_name is done $1 will take value 2 or more.
And when yum install rpm_name is done $1 will take a value 1
When doing yum update this works fine and my service is restarted.
Now i did yum remove rpm_name
And then did yum install rpm_name
I got an error saying the service is already stop. Means that the restart line got executed
Somewhow $1 is coming still >1 even though i removed the package.
what could be the reason for this. How can i correct it ?
Thanks
I am using the below code in my post deploy script :
if [ "$1" -ge 1 ]; then
service code-snip restart
else
service code-snip start
fi
As per my understanding when yum update rpm_name is done $1 will take value 2 or more.
And when yum install rpm_name is done $1 will take a value 1
When doing yum update this works fine and my service is restarted.
Now i did yum remove rpm_name
And then did yum install rpm_name
I got an error saying the service is already stop. Means that the restart line got executed
Somewhow $1 is coming still >1 even though i removed the package.
what could be the reason for this. How can i correct it ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$1 is the first argument, without seeing what the command is, I am not in a position to answer that if you want to check how many arguments are passed to a command
I.e, command argument1 argument2
$0 will have command
$1 will have argument1
$2 will have argument2
To check on the number of arguments I think the notation is $#_@
Usually a successful execution of a command, the status echo $? Or echo $status will be 0. The exit code variable differs based on the shell being used bash I think and sh uses $? Csh I think uses $status.
1 means there was an issue, different issues often have their own exit codes 127 often is related to segmentation fault when trying to run.
Most programs coders, include/publish or use the errno.h defined exit codes to convey the cause of an error.
I.e, command argument1 argument2
$0 will have command
$1 will have argument1
$2 will have argument2
To check on the number of arguments I think the notation is $#_@
Usually a successful execution of a command, the status echo $? Or echo $status will be 0. The exit code variable differs based on the shell being used bash I think and sh uses $? Csh I think uses $status.
1 means there was an issue, different issues often have their own exit codes 127 often is related to segmentation fault when trying to run.
Most programs coders, include/publish or use the errno.h defined exit codes to convey the cause of an error.
ASKER
Hi,
Here i as refering to a special case as mentioned in :
https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s04s05.html
Here i as refering to a special case as mentioned in :
https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s04s05.html
Where did you add code-snip as a service?
Posting a snippet as you have lacks context on what you have, trying to do and what is actually happening.
$1 is a variable reference, in different context it has different values.
You created a code-snip rpm package that runs code-snip as a service?.
Posting a snippet as you have lacks context on what you have, trying to do and what is actually happening.
$1 is a variable reference, in different context it has different values.
You created a code-snip rpm package that runs code-snip as a service?.
ASKER
also one more thing i want to confirm
as per documentation $1 gives th count of versions of package
so does $1 when doing yum install always return 1 ?
and 0 on doing yum remove, 2 on yum update.
in what cases can the value be greater than 2