Sponsored Content
Full Discussion: Reset $1 variable
Top Forums Shell Programming and Scripting Reset $1 variable Post 302934813 by Elmassimo on Wednesday 11th of February 2015 04:49:14 AM
Old 02-11-2015
Linux Reset $1 variable

Hi all,

I'm using a scipt with one input and one output.
I'm referring to the input by $1
after executing a command line, I'm getting the output via $1.
Normally, the $1 shouldn't get the same values between the first call and the second.
Is there a solution to force my second call for $1 to get the value of $PS -efo pcpu,vsz,arg

Here is my script:
Code:
SWAPINFO="/usr/sbin/swapinfo"
PS="/usr/bin/ps"
AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
SORT="/usr/bin/sort"
TAIL="/usr/bin/tail"


MYPAT="$1"
Availability=0
export UNIX95=1
VAR=$($SWAPINFO -ta | $GREP memory | $AWK ' { print $2 } ')
MYCPU=` $PS -efo pcpu,vsz,args | $GREP -v COMMAND | $GREP -v awk | $GREP "$MYPAT" | $SORT -k 1 | $TAIL -1 | $AWK -v var=$VAR -v pattern="$MYPAT" ' { print $1 } '`
echo $MYCPU


Last edited by Don Cragun; 02-11-2015 at 06:12 AM.. Reason: Fix CODE and ICODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

System Reset

Hi: Problem: Whenever I plug-in or out a serial cable from Sun 220 Server it resets itself and gives me OK prompt. I need to use one dumb terminal for two 220s. Any suggestions or comments will be highly appreciated. (2 Replies)
Discussion started by: s_aamir
2 Replies

2. UNIX for Dummies Questions & Answers

Tape Reset?????

I'm changing from SCO UNIX to Red Hat Linux. In the UNIX box when backing up my data to tape I usually do this: tape reset sleep 5 nohup tar ................... I want to know if there is a way to do "tape reset" in Red Hat Linux. (1 Reply)
Discussion started by: rrivas
1 Replies

3. HP-UX

reset console

I have HP-UX 11i. My serial console is not responding to any input. How can I reset the console without rebooting the system? I can telnet in with no problem and system runs fine other than the console. Thanks. (2 Replies)
Discussion started by: mizzleman
2 Replies

4. Forum Support Area for Unregistered Users & Account Problems

reset email id

please reset my email id (0 Replies)
Discussion started by: beed123
0 Replies

5. OS X (Apple)

Permission Reset?

OSX 10.4.11 I installed an app. I am logged in as Admin. When I launch Limewire I get: You do not have permission to open the application "xxxx". How can I get around this? I tried resetting permission on the terminal and I still get it. (3 Replies)
Discussion started by: coopns
3 Replies

6. UNIX for Advanced & Expert Users

Password reset

Can anyone tell me if it is possible to have cron change your password every month from an encrypted list of passwords?I have several servers I hardly ever go near but when I do the password has always expired and it takes a long time to get the administrators to reset it for me. I was thinking... (4 Replies)
Discussion started by: steadyonabix
4 Replies

7. Emergency UNIX and Linux Support

The connection was reset

Hi Folks, I have recently started Apache on my Fedora 11. I placed a working html file in the ServerRoot. I can wget and telnet from within the localhost and access the index.html. My telnet to port 80 from another machine works fine but when I try to access the web page through Firefox I... (8 Replies)
Discussion started by: jacki
8 Replies

8. OS X (Apple)

Reset Password

So my dad bought an iMac from my mom, but she does not know the admin password anymore. I read on the apple forums that I should look here for help on resetting the password. The iMac runs OSX 10.6.3. I would really appreciate any help. Thanks (3 Replies)
Discussion started by: PhsycoDragon
3 Replies

9. UNIX for Beginners Questions & Answers

Variable inside while loop got reset

hi, I am using hp unix server and not getting variable output present inside the while loop. I have tried changing the code and need to verify whether it is proper practice of code. I am expecting the output of varible RUN_FILE 3 to TRUE which i get inside the while loop. RUN_FILE 1=TRUE... (8 Replies)
Discussion started by: gowthamsoft
8 Replies

10. UNIX for Beginners Questions & Answers

Reset Password

Installed Solaris 11.3 Gnome Desktop It wouldn't let me log on at lock screen after first reboot. It finally relented and let me in after about 20 logon failures. How do I reset password now that I am in? (10 Replies)
Discussion started by: Solaris User
10 Replies
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/ksh93, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/ksh93, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh, and /usr/sfw/bin/zsh. /etc/shells overrides the default list. Invalid shells in /etc/shells could cause unexpected behavior, such as being unable to log in by way of ftp(1). FILES
/etc/shells list of shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.11 20 Nov 2007 shells(4)
All times are GMT -4. The time now is 10:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy