Sponsored Content
Top Forums Shell Programming and Scripting Why do these 2 methods result in different outcomes? Post 303021980 by BLinux on Wednesday 22nd of August 2018 03:41:34 AM
Old 08-22-2018
thank you everyone. i got it now. i was confused about the return behavior of (( counter++ )). so, to get what i was expecting, i can use either:

Code:
(( ++counter ))
(( counter = counter + 1 ))
counter=$((counter+1))
let counter=counter+1

all of the above would return 0. where as:

Code:
(( counter++ ))

would return 1 (when counter=0), but return 0 after counter > 0.




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 08-22-2018 at 05:24 AM.. Reason: Added CODE tags.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

file transfer Methods

I would like to write shell script to transfer some ASCII files from HPUX server to Linux server or vice-versa. What options I have for file transfer Methods. 1) FTP 2) rcp 3) HTTP 4)Whatelse? (2 Replies)
Discussion started by: Teh Tiack Ein
2 Replies

2. What is on Your Mind?

Predict Future Outcomes in Our Event Prediction Market

Folks love to predict the future, so we have enabled predicting the future for members. So, please enjoy placing your Forum Bits predicting future outcomes in our new Event Prediction Market. Current events you can predict include science, technology, M&A and other global events: Oracle... (0 Replies)
Discussion started by: Neo
0 Replies

3. Shell Programming and Scripting

Methods to SSH (Perl)...

Can anyone break down the different methods of using SSH in perl? I'm currently using Net::SSH::Expect, which allows me to login to a machine and execute multiple commands without having to ssh again. This feature of holding the session works well for me, but it's slow. If I set timeouts to 4... (3 Replies)
Discussion started by: mrwatkin
3 Replies

4. UNIX for Advanced & Expert Users

yum provides methods

What is the difference between these yum provides and whatprovides methods? I know provides and whatprovides give the same results, but different methods of */ and \* give different results. Also whether you put */ and \* in front of the string or behind the string give different results. I have... (0 Replies)
Discussion started by: cokedude
0 Replies

5. Solaris

Unix learning methods

I have recently completed Solaris 10 System Administration book by Bill Calkins. Now I want to learn more about UNIX. I have tried to research online but there is too much information and I am sort of overwhelmed and don't know where to start. Can anybody give some idea on how to pursue my learning... (3 Replies)
Discussion started by: saudsos
3 Replies

6. Shell Programming and Scripting

Perl Methods Calling

Hello I am on my way to improve my wonderful Perl skills, I got an issue which I want to share with you all. I have a Perl module which looks like package Cocoa; require Exporter; @ISA = qw(Exporter); my $a=''; my $b=''; my $c=''; sub new { my $this = shift; # Create... (8 Replies)
Discussion started by: adisky123
8 Replies

7. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

8. Linux

Help with PAM Logging methods.

Hi Folks, Would like to understand if there exists any method to write the logs for LDAP authenticated users and Local Users separately in two different files. If not, then do I distinguish whether the user is LDAP or local without looking at passwd. Bye the way, I am trying this weird... (0 Replies)
Discussion started by: awk-admirer
0 Replies

9. UNIX for Beginners Questions & Answers

One Line Command how to use pipe statements to execute and comment on multiple possible outcomes

Hello Forum, I'm looking to expand the following command: INACTIVE_KERNELS=$(python -mplatform | grep -qi red && rpm -qa | grep '^kernel-' |grep -vE `uname -r` | paste -sd \; || echo "Not Red Hat Server") Currently this command will check if my server is RedHat server using the grep -qi... (6 Replies)
Discussion started by: greavette
6 Replies
PMC_CONTROL(2)						      BSD System Calls Manual						    PMC_CONTROL(2)

NAME
pmc_control, pmc_get_info -- Hardware Performance Monitoring Interface LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/pmc.h> int pmc_control(int ctr, int op, void *argp); int pmc_get_info(int ctr, int op, void *argp); DESCRIPTION
pmc_get_info() returns the number of counters in the system or information on a specified counter ctr. The possible values for op are: PMC_INFO_NCOUNTERS When querying the number of counters in the system, ctr is ignored and argp is of type int *. Upon return, the integer pointed to by argp will contain the number of counters that are available in the system. PMC_INFO_CPUCTR_TYPE When querying the type of a counter in the system, ctr refers to the counter being queried, and argp is of type int *. Upon return, the integer pointed to by argp will contain the implementation-dependent type of the specified counter. If ctr is -1, the integer pointed to by argp will contain the machine-dependent type describing the CPU or counter configuration. PMC_INFO_COUNTER_VALUE When querying the value of a counter in the system, ctr refers to the counter being queried, and argp is of type uint64_t *. Upon return, the 64-bit integer pointed to by argp will contain the value of the specified counter. PMC_INFO_ACCUMULATED_COUNTER_VALUE When querying the value of a counter in the system, ctr refers to the counter being queried, and argp is of type uint64_t *. Upon return, the 64-bit integer pointed to by argp will contain the sum of the accumulated values of specified counter in all exited sub- processes of the current process. pmc_control() manipulates the specified counter ctr in one of several fashions. The op parameter determines the action taken by the kernel and also the interpretation of the argp parameter. The possible values for op are: PMC_OP_START Starts the specified ctr running. It must be preceded by a call with PMC_OP_CONFIGURE. argp is ignored in this case and may be NULL. PMC_OP_STOP Stops the specified ctr from running. argp is ignored in this case and may be NULL. PMC_OP_CONFIGURE Configures the specified ctr prior to running. argp is a pointer to a struct pmc_counter_cfg. struct pmc_counter_cfg { pmc_evid_t event_id; pmc_ctr_t reset_value; uint32_t flags; }; event_id is the event ID to be counted. reset_value is a value to which the counter should be reset on overflow (if supported by the implementation). This is most useful when profiling (see PMC_OP_PROFSTART, below). This value is defined to be the number of counter ticks before the next overflow. So, to get a profiling tick on every hundredth data cache miss, set the event_id to the proper value for ``dcache-miss'' and set reset_value to 100. flags Currently unused. PMC_OP_PROFSTART Configures the specified ctr for use in profiling. argp is a pointer to a struct pmc_counter_cfg as in PMC_OP_CONFIGURE, above. This request allocates a kernel counter, which will fail if any process is using the requested counter. Not all implementations or coun- ters may support this option. PMC_OP_PROFSTOP Stops the specified ctr from being used for profiling. argp is ignored in this case and may be NULL. RETURN VALUES
A return value of 0 indicates that the call succeeded. Otherwise, -1 is returned and the global variable errno is set to indicate the error. ERRORS
Among the possible error codes from pmc_control() and pmc_get_info() are [EFAULT] The address specified for the argp is invalid. [ENXIO] Specified counter is not yet configured. [EINPROGRESS] PMC_OP_START was passed for a counter that is already running. [EINVAL] Specified counter was invalid. [EBUSY] If the requested counter is already in use--either by the current process or by the kernel. [ENODEV] If and only if the specified counter event is not valid for the specified counter when configuring a counter or starting profiling. [ENOMEM] If the kernel is unable to allocate memory. SEE ALSO
pmc(1), pmc(9) HISTORY
The pmc_control() and pmc_get_info() system calls appeared in NetBSD 2.0. BSD
October 27, 2005 BSD
All times are GMT -4. The time now is 12:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy