<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic shell help - How to include prefix information when copying data in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445985#M851765</link>
    <description>I'm sure someone can help with this.&lt;BR /&gt;&lt;BR /&gt;I want a general purpose command that either prefixes or appends information when displaying or copying data.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ndname=`/usr/bin/uname -n`&lt;BR /&gt;&lt;BR /&gt;&lt;COMMAND&gt; /etc/passwd -F: -p $ndname&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;&lt;BR /&gt;server1:root:*:...&lt;BR /&gt;server1:adm:*:...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;where server1 is the host name and the remaining data is info returned from cat /etc/passwd.&lt;BR /&gt;&lt;BR /&gt;server1 prefixes every record.&lt;BR /&gt;&lt;BR /&gt;Thanks... Jack...&lt;BR /&gt;&lt;/COMMAND&gt;</description>
    <pubDate>Fri, 17 Dec 2004 08:43:24 GMT</pubDate>
    <dc:creator>Jack C. Mahaffey</dc:creator>
    <dc:date>2004-12-17T08:43:24Z</dc:date>
    <item>
      <title>shell help - How to include prefix information when copying data</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445985#M851765</link>
      <description>I'm sure someone can help with this.&lt;BR /&gt;&lt;BR /&gt;I want a general purpose command that either prefixes or appends information when displaying or copying data.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ndname=`/usr/bin/uname -n`&lt;BR /&gt;&lt;BR /&gt;&lt;COMMAND&gt; /etc/passwd -F: -p $ndname&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;&lt;BR /&gt;server1:root:*:...&lt;BR /&gt;server1:adm:*:...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;where server1 is the host name and the remaining data is info returned from cat /etc/passwd.&lt;BR /&gt;&lt;BR /&gt;server1 prefixes every record.&lt;BR /&gt;&lt;BR /&gt;Thanks... Jack...&lt;BR /&gt;&lt;/COMMAND&gt;</description>
      <pubDate>Fri, 17 Dec 2004 08:43:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445985#M851765</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-12-17T08:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: shell help - How to include prefix information when copying data</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445986#M851766</link>
      <description>How about something like:&lt;BR /&gt;PREFIX="$(hostname)_$(logname)_"&lt;BR /&gt;&lt;BR /&gt;$PREFIX whould yieled "host1_joeblow_" which could be used in file naming i.e.:&lt;BR /&gt;&lt;BR /&gt;OUTFILE="${PREFIX}file1" which would expand to host1_joeblow_file1</description>
      <pubDate>Fri, 17 Dec 2004 08:51:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445986#M851766</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2004-12-17T08:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: shell help - How to include prefix information when copying data</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445987#M851767</link>
      <description>ndname=`/usr/bin/uname -n`&lt;BR /&gt;&lt;BR /&gt;cat /etc/passwd | while read LINE&lt;BR /&gt;do&lt;BR /&gt;.. echo $ndname ":" $LINE&lt;BR /&gt;done</description>
      <pubDate>Fri, 17 Dec 2004 08:56:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445987#M851767</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2004-12-17T08:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: shell help - How to include prefix information when copying data</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445988#M851768</link>
      <description>I was hoping for a general purpose utility/script rather than looping through the file(s).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Reason for the script is to be able to consolidate sulogs, sudo logs, lastb output from mulitple servers into a single file so that one file can be examined rather than many.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Examples:&lt;BR /&gt;&lt;BR /&gt;plogger is the script name that contains the capability.&lt;BR /&gt;&lt;BR /&gt;# plogger -p "server1:sulog:" /var/adm/sulog&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;# cat /var/adm/sulog | plogger -p "server1:sulog:" &amp;gt; /tmp/sulog_with_prefix&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 09:11:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445988#M851768</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-12-17T09:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: shell help - How to include prefix information when copying data</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445989#M851769</link>
      <description>here is a good start&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;file=""&lt;BR /&gt;cmd=""&lt;BR /&gt;preText=""&lt;BR /&gt;preCmd=""&lt;BR /&gt;postText=""&lt;BR /&gt;postCmd=""&lt;BR /&gt;&lt;BR /&gt;for i in $@&lt;BR /&gt;do&lt;BR /&gt;        case "$i" in&lt;BR /&gt;        "-preText")&lt;BR /&gt;                shift;preText="$1"&lt;BR /&gt;                ;;&lt;BR /&gt;        "-postText")&lt;BR /&gt;                shift;postText="$1"&lt;BR /&gt;                ;;&lt;BR /&gt;        "-preCmd")&lt;BR /&gt;                #just take first line of command output&lt;BR /&gt;                # i.e. don't want multi line command&lt;BR /&gt;                ###&lt;BR /&gt;                # might want to do some checking on what the command is&lt;BR /&gt;                # might not want to run just anything&lt;BR /&gt;                ###&lt;BR /&gt;                shift;preCmd=$($1 | awk '{print $0;exit;}')&lt;BR /&gt;                ;;&lt;BR /&gt;        "-postCmd")&lt;BR /&gt;                shift;postCmd=$($1 | awk '{print $0;exit;}')&lt;BR /&gt;                ;;&lt;BR /&gt;        "-f"|"-file")&lt;BR /&gt;                shift;file="$1"&lt;BR /&gt;                ;;&lt;BR /&gt;        "-c"|"-cmd")&lt;BR /&gt;                shift;cmd="$1"&lt;BR /&gt;                ;;&lt;BR /&gt;        *) print "your error message";exit 1;;&lt;BR /&gt;        esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# do some error checking&lt;BR /&gt;# -z $file &amp;amp;&amp;amp; -z $cmd&lt;BR /&gt;# -n $file &amp;amp;&amp;amp; -n $cmd&lt;BR /&gt;# etc&lt;BR /&gt;###&lt;BR /&gt;&lt;BR /&gt;# you'll need to do want you want&lt;BR /&gt;# about weather preText comes before preCmd&lt;BR /&gt;# or what order&lt;BR /&gt;###&lt;BR /&gt;if [[ -n $file ]] ;then&lt;BR /&gt;&lt;BR /&gt;        cat $file |&lt;BR /&gt;        while read line&lt;BR /&gt;        do&lt;BR /&gt;                print "${preText}${preCmd}${line}${postCmd}${postText}"&lt;BR /&gt;        done&lt;BR /&gt;else&lt;BR /&gt;        $cmd |&lt;BR /&gt;        while read line&lt;BR /&gt;        do&lt;BR /&gt;                print "${preText}${preCmd}${line}${postCmd}${postText}"&lt;BR /&gt;        done&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 11:01:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445989#M851769</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2004-12-17T11:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: shell help - How to include prefix information when copying data</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445990#M851770</link>
      <description>WE can do with good shell scripting more effectivly. I hope you got the solution, but there is a suggestion to use this script as,&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;######################################################################&lt;BR /&gt;# Execution :&lt;BR /&gt;#  logcon &lt;HOSTNAME&gt; &lt;LOGFILE&gt;&lt;BR /&gt;#  &lt;BR /&gt;# Requirement :&lt;BR /&gt;#  Remote login enablement with r* commands&lt;BR /&gt;######################################################################&lt;BR /&gt;&lt;BR /&gt;PATH=$PATH:/usr/bin/:/usr/sbin/:/bin/:/sbin/:./usr/local/bin/&lt;BR /&gt;&lt;BR /&gt;if [[ $# -ne 0 ]]&lt;BR /&gt;then&lt;BR /&gt;   echo "&lt;USAGE&gt; : logcon &lt;HOSTNAME&gt; &lt;LOGFILE&gt;&lt;BR /&gt;   exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;host=$1&lt;BR /&gt;basename=$(basename $2)&lt;BR /&gt;filename=$2&lt;BR /&gt;&lt;BR /&gt;rcp $host:$filename /tmp/$basename_$host.tmp&lt;BR /&gt;&lt;BR /&gt;if [[ -f /tmp/$filename_$host ]]&lt;BR /&gt;then&lt;BR /&gt;     while read line; do&lt;BR /&gt;       echo "$host:$basename # $line"&lt;BR /&gt;     done &amp;lt; /tmp/$filename_$host.tmp &amp;gt; /tmp/$basename_$host_$(date +"%d-%m-%y")&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# Remove temporary file&lt;BR /&gt;rm -f /tmp/$filename_$host.tmp&lt;BR /&gt;&lt;BR /&gt;# Normal exit&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;If you are interested in r* commands(remsh,rcp without passwd login into server).&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;/LOGFILE&gt;&lt;/HOSTNAME&gt;&lt;/USAGE&gt;&lt;/LOGFILE&gt;&lt;/HOSTNAME&gt;</description>
      <pubDate>Fri, 17 Dec 2004 11:33:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-help-how-to-include-prefix-information-when-copying-data/m-p/3445990#M851770</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-12-17T11:33:29Z</dc:date>
    </item>
  </channel>
</rss>

