Tag Archives: PID

Determine uniqueness of pid to name output files

By vkumbhakarna

Hi,

We’ve a process on AIX UNIX server which is executed by multiple uses during a day. I wish to create a log file for every time the process is executed. I wish to know how unique are PID(s) on AIX UNIX servers if I were to name the log files with and ?

E.g. If I create my output files having the details such as

Code:

`date +%Y%m%d`_${$}_out.csv


With my limited understanding of UNIX and from what I’ve read on the forum http://www.unix.com/unix-advanced-expert-users/2896-obtaining-process-id-pid.html AIX system sequentially assigns a limited set of PIDs and re-utilizes them as and when processes get freed and slot is available for allocation by dispatcher.

Please suggest a suitable way to uniquely identify the process execution during the day. I am also considering adding datetime hh:mm:ss to the log name to uniquely identify the same.

Thanks,

From: http://www.unix.com/unix-dummies-questions-answers/221535-determine-uniqueness-pid-name-output-files.html

Hanwha SolarOne Launches New Generation HSL Series

By Business Wirevia The Motley Fool

Filed under:

Hanwha SolarOne Launches New Generation HSL Series

“Stronger, smaller and lighter module with anti-PID technology”

SHANGHAI–(BUSINESS WIRE)– Hanwha SolarOne Co. Ltd. (Hanwha SolarOne), a top-10 global photovoltaic manufacturer of high-quality solar modules at competitive costs, today announced the global launch of its new generation modules – the HSL Series. Compared to previous generation modules, these offer a smaller and lighter design, higher power output and enhanced durability, with new features like anti-PID (potential induced degradation) technology, anti-salt mist corrosion and increased snow and wind loads.

“The launch of Hanwha SolarOne’s new polycrystalline modules marks a significant milestone in the evolution of our product offerings. Made with Hanwha SolarOne’s industry-leading technology, these modules deliver high performance at a competitive cost to meet the needs of our customers,” said Hanwha SolarOne President Min-Su Kim. “As the world’s most reliable partner in solar, we will continue to develop a wider range of industry-leading technology and solutions that provide the best value for our customers.”

Hanwha SolarOne’s HSL Series is built for utility, commercial and residential applications. Approximately 2 percent smaller than the previous generation, these modules yield an average 2 percent higher module efficiency. With 30 percent greater protection against snow and 65 percent better wind resistance, they can withstand a snow load of up to 7000pa and a wind load of up to 4000pa. Additionally, at 1.5kg lighter than the previous generation, the new HSL Series is easier and more cost-effective to pack, transport and install. HSL60 Poly and HSL72 Poly are the first among HSL Series modules to have passed the stringent TUV Rheinland PID test.

Backed by a 25-year linear power warranty and 12-year workmanship warranty, HSL Series modules have enhanced quality assurance with International Electrotechnical Commission (IEC) and Underwriters Laboratories (UL) certification, signaling Hanwha SolarOne’s commitment to delivering high-quality products to every region in the world.

About Hanwha SolarOne

Hanwha SolarOne Co., Ltd. (NAS: HSOL) is one of the top 10 photovoltaic manufacturers in the world, providing cost-competitive, high quality PV modules. It is the flagship company of Hanwha Group, a FORTUNE global 500 company. Hanwha SolarOne serves the utility, commercial, government and residential markets for a growing network of third-party distributors, OEM manufacturers and system integrators. The company maintains a strong presence worldwide, with employees located throughout Europe, North America and …read more

Source: FULL ARTICLE at DailyFinance

Getting child process id for a given PID

By Priya Amaresh

HI
Am trying to get child process id for a PID using ksh..

Code:

ps -ef | grep xntpd
root 3342472 2228308 0 12:17:40 - 0:00 /usr/sbin/xntpd
root 4522024 6488316 0 12:18:56 pts/0 0:00 grep xntpd
root 6291614 3342472 0 12:17:40 - 0:00 /usr/sbin/xntpd


Here now i need to grep the PID “3342472” and I can get the PID using

Code:

parentId=`ps -ef | grep "xntpd" | awk -F " " '{print $2}'`


But I need to return the value of its child process id (6291614).. How to make it..

Please help..

Thanks in advance..

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Kill idle Process using a script

By MaggieL

Hi,
I need a script that can automatically kill all processes named “webrepn” and “webrebw” if idle for more than 30 minutes.

Then I will have a Cron Job to run the script every night or 2-3 times a day depends on how this script helps.

Right now, I run “ps -ef | grep webrebn” and “kill -9 PID” to kill the idle processes using PID if I see any. Then repeat for “webrepw”. The problem is if I forget to do so for couple days, my system will be very slow.
Would anybody help me out here?

I am using DB2 database in AIX 5.3 server.

Any help will be greatly appreciated.

Thank you,
Maggie

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Cut pid from ps using cut command

By ran ber

hay
i am trying to get JUST the PID from the ps command.
my command line is:

ps -ef | grep “mintty” | cut -d’ ‘ -f2
but i get an empty line. i assume that the delimiter is not just one space character, but can’t figure out what should i do in order to do that.

i know i can use awk or cut -c1-4 (the pid is in characters 1-4), but i don’t want to use them.

is it possible to achieve my goal using cut -f and a combination or -d or -s?

thanks

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Check if PID exists

By mohtashims

In a Shell Script what is the most generic way to find in the PID exists or not.

If it does not exist how can I echo the user “PID does not exist” & terminate the unix script ?

If the command can work on most flavors of operating system the more useful I will find it to be.

Current system is HP-UX.

Thank you for your suggestions.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Tricky situation getting IP address

By mohtashims

Hi,

I have a multihomed system HP-UX with two NIC cards having IP address 10.9.0.13 & 10.9.0.45

I have two weblogic servers running one listening on “10.9.0.13” and the other on “10.9.0.45”

Given a PID how is it possible to extract the IP Address that the weblogic server is using and store it in a bash variable “myh” ?

I am looking for a solution for HP-UX and then for all Linux and Unix systems so if you could share some solution for HP-UX and others as well.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

James Hunt: Upstart 1.7 released

We’ve just released Upstart 1.7 which expands Upstarts abilities a lot. I’ll follow up with a further post explaining what these changes mean for users as this release is soon to appear in Ubuntu.

Summary of changes

  • New initctl commands: set-env, unset-env, get-env, list-env, reset-env, list-sessions (all except last with corresponding D-Bus methods).
  • New D-Bus-only signals EventEmitted, Restarted, and EndSession method.
  • Ability to run with PID >1 to allow Upstart to manage a user session.
    Running Upstart as a ‘Session Init‘ in this way provides features
    above and beyond those provided by the original User Jobs such that
    the User Job facility has been removed entirely: to migrate from
    a system using User Jobs, simply ensure the user session is started with
    init –user‘.
  • New upstart-event-bridge bridge which proxies system-level events down to Session Inits, allowing users jobs to react to udev events.
  • Ability to read job configuration and override files from multiple freedesktop-compliant locations (Session Init only).
  • Ability to shutdown both via a system shutdown request and via a user logout request (Session Init only).
  • Additionally, there are a few bug fixes and 94 new tests.

Thanks to all the contributors, reviewers, testers and users!

Download

Get it here https://launchpad.net/upstart

…read more
Source: FULL ARTICLE at Planet Ubuntu

Change user settings..

By Rantu

Hi,

I have 48 cores in my server. I want to assign 50% of the cores to certain programs and rest to some other programms. I found the command “taskset” very good option to assign cpu afinity to already running programms or newly created programms.

But the problem is even if i set a cron to change the newly created PID‘s by a specific user, it will take effect only every minute. So if PID‘s are created in seconds, then this command “taskset” fails to assign cpu affinity to newly created PID‘s.

So is there any way I can modify the user settings so that everytime a new PID is created with that user ownership, then my taskset commands runs automatically.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Using expect command, spawn will not start sftp process

By ltyrrell

Hi all,

I have a script that runs sftp with expect so I can login and send a file in a cronjob. I’ve installed this on a couple other servers and it has been fine. However, this time on this machine, it seems to be giving me an issue. It won’t move past the spawn sftp command and return a linux PID.

First the basics:

The server is running Red Hat Linux Release 7.3 (Valhalla)
uname -a shows Linux 2.4.20-28.7smp #1 SMP i686

I installed Expect-5.45 and Tcl-8.5.12

This is the script:

#!/usr/bin/expect -f
set location “.”

spawn sftp username@secureftp.ftpserver.com
expect “password:”
send “userpwr”;
set timeout -1
send “put localfile.txt remotefile.txtr”;
send “quitr”
expect eof

Pretty simple and straight forward, right?

When I run it with the -d flag to see what is happening, I get this output:
expect version 5.45
argv[0] = /usr/bin/expect argv[1] = -d argv[2] = ./scriptname.ftp
set argc 0
set argv0 “./scriptname.ftp
set argv “”
executing commands from command file ./scriptname.ftp
spawn sftp username@secureftp.ftpserver.com
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child

And that is where it stops. It does not give me “spawn: returns [PID number]” and does not move on.

Any ideas? What am I missing here?

I appreciate any help you can give me, I’ve been searching and searching for an answer to no avail.

Thank you,

Laura

Source: FULL ARTICLE at The UNIX and Linux Forums

Terminate processes for CLOSE_WAIT status of TCP

By EAGL€

Hello Friends,

First of all im sorry for spending extra space in DB of forum with this thread, i know there would be a solution if i kept searching,

I need to terminate the process which causes CLOSE_WAIT status of TCP connection via port 8103:

Code:

-bash-3.00$ netstat -na | grep 8103
127.0.0.1.8103 127.0.0.1.63876 49152 0 49152 0 CLOSE_WAIT
127.0.0.1.8103 127.0.0.1.39286 49152 0 49152 0 CLOSE_WAIT
127.0.0.1.8103 127.0.0.1.60796 49152 0 49152 0 CLOSE_WAIT
*.8103 *.* 0 0 49152 0 LISTEN
127.0.0.1.8103 127.0.0.1.62363 49152 0 49152 0 CLOSE_WAIT


I found this script FPMurphy posted on a thread here but i couldnt make it work for Solaris:

Code:

PORT=8103
PIDS=`ps -ef | sed 1d | awk '{print $2}'`
for pid in $PIDS
do
/usr/proc/bin/pfiles $pid 2>/dev/null | grep -q "port: $PORT"
if [[ $? -eq 0 ]] ; then
echo "Port: $PORT is being used by PID: c"
ps -o pid -o args -p $PID | sed 1d
fi
done


Function of grep -q in Linux is not provided on solaris.. So i got this:

Code:

grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .


So i tried below part with xargs even without being sure about how exact output of “/usr/proc/bin/pfiles $pid” part seems like, im sorry a bit stuck with time…

Code:

PORT=8103
PIDS=`ps -ef | sed 1d | awk '{print $2}'`
for pid in $PIDS
do
/usr/proc/bin/pfiles $pid 2>/dev/null | xargs grep "port: $PORT"
if [[ $? -eq 0 ]] ; then
echo "Port: $PORT is being used by PID: c"
ps -o pid -o args -p $PID | sed 1d
fi
done


I had this meaningless output:

Code:

grep: can't open 23534:
grep: can't open -bash
grep: can't open Current
grep: can't open rlimit:
grep: can't open 256
grep: can't open file
grep: can't open descriptors
grep: can't open 0:
grep: can't open S_IFCHR
grep: can't open mode:0600
grep: can't open dev:292,0
grep: can't open ino:12582922
grep: can't open uid:100


Any suggestion welcome,

Thanks in advance,
Kind Regards

Source: FULL ARTICLE at The UNIX and Linux Forums

PID of listening ports

By tt77

I ran ‘sudo netstat -ntpl’ and got the following without PID

Code:

tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:38977 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:34253 0.0.0.0:* LISTEN -


I check with ‘sudo rpcinfo -p’ and found out that 2049 and 34253 are used by nfs and nlockmgr. But nothing for port 38977. ‘sudo lsof -i :38977’ shows nothing.
How can I find out who is listening at 38977?

On another machine with similiar setup, I got

Code:

tcp 0 0 0.0.0.0:59517 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:52968 0.0.0.0:* LISTEN -


with 2049 and 52968 from nfs and nlockmgr, which left port 59517. I think it must be something I installed, and I want to find out what.

Thanks in advance.

tt

Source: FULL ARTICLE at The UNIX and Linux Forums

awk experts please help

By mirwasim

I have a log file of 60 MB with 20k records which contains data like below.
I have placed data for two different numbers. line number will be same always
I have set start and end of log as bold character

Code:

D 2012-12-02 23:16:17.271 ssapp1025 dm:1710.1 dm_sms.c:394 1:ssapp1025:UnknownProgramName:0:Thread 47:600002:1354450576:0
DM BE [5] with PID [1710] doing OP on socket [5]
D 2012-12-02 23:16:17.272 ssapp1025 dm:1710.1 dm_sms.c:406 1:ssapp1025:UnknownProgramName:0:Thread 47:600002:1354450576:0
dm_if_process_op called input flist
# number of field entries allocated 20, used 4
0 PIN_FLD_POID POID [0] 0.0.0.10 /event/notification/threshold -1 0
0 TDB_FLD_MSG_TYPE STR [0] "Threshold Notification"
0 PIN_FLD_MSG_ID STR [0] "004"
0 TDB_FLD_MSG_DATA SUBSTRUCT [0] allocated 20, used 11
1 PIN_FLD_SERVICE_TYPE STR [0] "/service/ip/gprs"
1 PIN_FLD_SPONSOREE_FLAGS INT [0] 0
1 PIN_FLD_DELIVERY_PREFER ENUM [0] 1
1 PIN_FLD_MSISDN STR [0] "0407795932"
1 PIN_FLD_EMAIL_ADDR STR [0] ""
1 PIN_FLD_PERCENT DECIMAL [0] 101.56
1 TDB_FLD_ACTG_NEXT_DATE STR [0] "20121218000000"
1 TDB_FLD_ACTG_LAST_DATE STR [0] "20121118000000"
1 PIN_FLD_TOTAL_BYTES DECIMAL [0] 1048576
1 PIN_FLD_UNITS ENUM [0] 12
1 PIN_FLD_UNIQUE_ID STR [0] "2891358277113543429461000020"
D 2012-12-02 23:16:17.466 ssapp1025 dm:1710.1 dm_sms.c:569 1:ssapp1025:UnknownProgramName:0:Thread 47:600002:1354450576:0
dm_if_process_op output flist
# number of field entries allocated 20, used 5
0 PIN_FLD_POID POID [0] 0.0.0.10 /event/notification/threshold -1 0
0 TDB_FLD_MSG_TYPE STR [0] "Threshold Notification"
0 PIN_FLD_MSG_ID STR [0] "004"
0 TDB_FLD_MSG_DATA SUBSTRUCT [0] allocated 20, used 11
1 PIN_FLD_SERVICE_TYPE STR [0] "/service/ip/gprs"
1 PIN_FLD_SPONSOREE_FLAGS INT [0] 0
1 PIN_FLD_DELIVERY_PREFER ENUM [0] 1
1 PIN_FLD_MSISDN STR [0] "0407795932"
1 PIN_FLD_EMAIL_ADDR STR [0] ""
1 PIN_FLD_PERCENT DECIMAL [0] 101.56
1 TDB_FLD_ACTG_NEXT_DATE STR [0] "20121218000000"
1 TDB_FLD_ACTG_LAST_DATE STR [0] "20121118000000"
1 PIN_FLD_TOTAL_BYTES DECIMAL [0] 1048576
1 PIN_FLD_UNITS ENUM [0] 12
1 PIN_FLD_UNIQUE_ID STR [0] "2891358277113543429461000020"
0 PIN_FLD_RESULT ENUM [0] 1
D 2012-12-02 23:16:19.336 ssapp1025 dm:1709.1 dm_sms.c:394 1:ssapp1025:UnknownProgramName:0:Thread 20:600002:1354450578:0
DM BE [4] with PID [1709] doing OP on socket [5]
D 2012-12-02 23:16:19.337 ssapp1025 dm:1709.1 dm_sms.c:406 1:ssapp1025:UnknownProgramName:0:Thread 20:600002:1354450578:0
dm_if_process_op called input flist
# number of field entries allocated 20, used 4
0 PIN_FLD_POID POID [0] 0.0.0.10 /event/notification/threshold -1 0
0 TDB_FLD_MSG_TYPE STR [0] "Threshold Notification"
0 PIN_FLD_MSG_ID STR [0] "004"
0 TDB_FLD_MSG_DATA SUBSTRUCT [0] allocated 20, used 11
1 PIN_FLD_SERVICE_TYPE STR [0] "/service/ip/gprs"
1 PIN_FLD_SPONSOREE_FLAGS INT [0] 0
1 PIN_FLD_DELIVERY_PREFER ENUM [0] 1
1 PIN_FLD_MSISDN STR [0] "0422073457"
1 PIN_FLD_EMAIL_ADDR STR [0] ""
1 PIN_FLD_PERCENT DECIMAL [0] 100.13
1 TDB_FLD_ACTG_NEXT_DATE STR [0] "20121205000000"
1 TDB_FLD_ACTG_LAST_DATE STR [0] "20121105000000"
1 PIN_FLD_TOTAL_BYTES DECIMAL [0] 4718592
1 PIN_FLD_UNITS ENUM [0] 12
1 PIN_FLD_UNIQUE_ID STR [0] "3780151233613543386171000020"
D 2012-12-02 23:16:19.400 ssapp1025 dm:1709.1 dm_sms.c:569 1:ssapp1025:UnknownProgramName:0:Thread 20:600002:1354450578:0
dm_if_process_op output flist
# number of field entries allocated 20, used 5
0 PIN_FLD_POID POID [0] 0.0.0.10 /event/notification/threshold -1 0
0 TDB_FLD_MSG_TYPE STR [0] "Threshold Notification"
0 PIN_FLD_MSG_ID STR [0] "004"
0 TDB_FLD_MSG_DATA SUBSTRUCT [0] allocated 20, used 11
1 PIN_FLD_SERVICE_TYPE STR [0] "/service/ip/gprs"
1 PIN_FLD_SPONSOREE_FLAGS INT [0] 0
1 PIN_FLD_DELIVERY_PREFER ENUM [0] 1
1 PIN_FLD_MSISDN STR [0] "0422073457"
1 PIN_FLD_EMAIL_ADDR STR [0] ""
1 PIN_FLD_PERCENT DECIMAL [0] 100.13
1 TDB_FLD_ACTG_NEXT_DATE STR [0] "20121205000000"
1 TDB_FLD_ACTG_LAST_DATE STR [0] "20121105000000"
1 PIN_FLD_TOTAL_BYTES DECIMAL [0] 4718592
1 PIN_FLD_UNITS ENUM [0] 12
1 PIN_FLD_UNIQUE_ID STR [0] "3780151233613543386171000020"
0 PIN_FLD_RESULT ENUM [0] 1


Now I have script which fetch required details for me, but its taking a lot of time. below is script

Code:

#! /bin/ksh
for lines in `grep -n "PIN_FLD_PERCENT" $1 |cut -d':' -f1`
do
((lines=${lines}-11))
headerstr=`head -$lines $1 | tail -1 | sed -e 's/ //g'| cut -d' ' -f3`
if [ "$headerstr" = "input" ]; then
((lines=${lines}+16))
unique_id=`head -$lines $1|grep PIN_FLD_UNIQUE_ID | tail -1|cut -d'"' -f2`
lines=`grep -n $unique_id $1|tail -1|cut -d':' -f1`
((lines=${lines}-17))
end_t=`head -$lines $1|tail -1|cut -c7-22`
((lines=${lines}+12))
percentile=`head -$lines $1 | tail -1 | awk '{print $5}'`
outline=`grep -n $unique_id $1|head -1|cut -d':' -f1`
((outline=${outline}-17))
start_t=`head -$outline $1|tail -1|cut -c7-22`
echo "$unique_id, $start_t, $end_t, $percentile"
fi
done


data I want

Code:

2891358277113543429461000020, 2012-12-02 23:16:17 , 2012-12-02 23:16:17 , 101.56
3780151233613543386171000020, 2012-12-02 23:16:19 , 2012-12-02 23:16:19 , 100.13


Source: FULL ARTICLE at The UNIX and Linux Forums

Help capturing output of expect script

By mrkz1974

Hello there. I have an expect script that I use to routinely apply certain commands to all Cisco routers within our SSH network. The output file has been modified so only loopback IP addresses are shown if it ran succesfully, like this:

*******************************************
SSH Login successful for 10.x.x.1
*******************************************
SSH Login successful for 10.x.x.2
*******************************************
etc…

We recently transitioned to SSH, (and since I’m a network guy and not a programmer it was a PAIN to make this work). There is a request now to capture ALL the expect output and I’m wondering what the best way to do this would be without changing the edited output. Maybe write the whole thing to another file, maybe using another script to capture all the log from this script, I don’t know. Here’s the script:

Code:

#!/usr/local/bin/expect -f
proc sshLoginV2 {host} {
set timeout 10
set sshUser "USER"
set sshPass "PASS"
spawn -noecho /usr/bin/ssh -o StrictHostKeyChecking=no $sshUser@$host
expect {
"assword:" {
send "$sshPassr"
expect {
"*#" {
return "success: logged in via SSH to $host"
}
"Access denied" {
return "error: access denied, incorrect password sent to $host"
}
}
}
timeout {
return "error: SSH login to $host timed out"
}
eof {
return "error: connection to $host failed"
}
}
}
#---open input file
set infile [open IPLIST r]
#---set the send_slow variable to 1.05 seconds
set send_slow {1 .01}
#---set output file variable
set outfile [open SCRIPT-RESULTS.txt w]
#---set expect timeout variable to 10 seconds
set timeout 7
#---turn off screen logging
log_user 0
#---foreach line in the input file
foreach host [split [read $infile] "n"] {
#---have to flush STDOUT buffer on each iteration of loop
flush $outfile
puts $outfile "*******************************************"
#---set PID variable with pid of spawned ping
spawn /usr/sbin/ping6 $host
set pingSpId $spawn_id
expect {
-i $pingSpId eof {
catch {exp_close -i $pingSpId} a
catch {exp_wait -i $pingSpId} b
}
-i $pingSpId timeout {
puts "Ping timed out for $host"
puts $outfile "Error: Cannot ping $host"
puts $outfile "*******************************************n"
catch {exp_close -i $pingSpId} a
catch {exp_wait -i $pingSpId} b
continue
}
-i $pingSpId "no answer from $host" {
puts "No answer from $host"
puts $outfile "Error: Cannot ping $host"
puts $outfile "*******************************************n"
catch {exp_close -i $pingSpId} a
catch {exp_wait -i $pingSpId} b
continue
}
-i $pingSpId "unknown host $host" {
puts "Unknown host $host"
puts $outfile "Error: Cannot ping $host"
puts $outfile "*******************************************n"
catch {exp_close -i $pingSpId} a
catch {exp_wait -i $pingSpId} b
continue
}
-i $pingSpId "0 packets received" {
puts "Cannot ping host $host, 0 packets received"
puts $outfile "Error: Cannot ping $host"
puts $outfile "*******************************************n"
catch {exp_close -i $pingSpId} a
catch {exp_wait -i $pingSpId} b
continue
}
-i $pingSpId "$host is alive" {
puts "$host is alive"
catch {exp_close -i $pingSpId} a
catch {exp_wait -i $pingSpId} b
}
}
#---call sshLogin proc from common.tcl
set sshMsg [sshLoginV2 $host]
if {[regexp "error" $sshMsg]} {
puts $outfile "SSH Login failed for $host"
puts $outfile "Reason: $sshMsg"
continue
} elseif {[regexp "success" $sshMsg]} {
puts $outfile "SSH Login successful for $host"
} else {
puts $outfile "Not sure what happened to SSH login for $host"
continue
}
set tlntSpId $spawn_id
#---hit the enter key once, just to see prompt
send -s -i $tlntSpId "r"
expect {
-i $tlntSpId eof {
catch {exp_close -i $tlntSpId} a
catch {exp_wait -i $tlntSpId} b
}
-i $tlntSpId timeout {
puts $outfile "error: do not see switch prompt"
puts $outfile "*******************************************n"
send "exitr"
catch {exp_close -i $tlntSpId} a
catch {exp_wait -i $tlntSpId} b
}
-i $tlntSpId "*#"
}
#---set terminal length to 0
send -s -i $tlntSpId "term len 0r"
expect {
-i $tlntSpId eof {
catch {exp_close -i $tlntSpId} a
catch {exp_wait -i $tlntSpId} b
}
-i $tlntSpId timeout {
puts $outfile "error: timeout sending code to $host"
puts $outfile "*******************************************n"
send "exitr"
catch {exp_close -i $tlntSpId} a
catch {exp_wait -i $tlntSpId} b
}
-i $tlntSpId "*#"
}
#---send commands
send -s -- "sh dlsw transparent map r"
expect *
sleep .1
send -s -- "sh int loopback 0 | incl 10.r"
expect *
sleep .2
send -s -- "exitr"
puts $outfile "*******************************************n"
flush $outfile
#---send exit to switch
send -s -i $tlntSpId "exitr"
expect {
-i $tlntSpId eof {
catch {exp_close -i $tlntSpId} a
catch {exp_wait -i $tlntSpId} b
}
-i $tlntSpId timeout {
puts $outfile "error: timeout exiting $member on $host"
puts $outfile "*******************************************n"
send "exitr"
catch {exp_close -i $tlntSpId} a
catch {exp_wait -i $tlntSpId} b
}
}
}
close $outfile


To recap, I’m looking to write for the whole logging output to another file and I’m wodering what is the best way to do this. Thanks!

Source: FULL ARTICLE at The UNIX and Linux Forums

Who -u gives different output if run from cron than if run from terminal?

If I run ‘who -u’ interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this:
testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy)

running the same through cron I get:
testuser pts/0 2012-12-09 02:32 00:05 2163 (host.xx.yy)

I want to check for idle ttys and thus tried to look at field 6 but my script fails because if run through cron I get the PID instead of the idle time.

I can not find anything about output format in the man page of who.

Is there an easy way to get a standardized output from who?
Source: The UNIX and Linux Forums