<?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 Re: Qualifying variables across files in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084594#M92091</link>
    <description>Hey&lt;BR /&gt;&lt;BR /&gt;you could also grep the $WASLOGS file like this:&lt;BR /&gt;&lt;BR /&gt; for FILE in $(grep ${DMGR} $WASLOGS)&lt;BR /&gt;&lt;BR /&gt;then you get only the files which contains $DMGR&lt;BR /&gt;&lt;BR /&gt;hope this helps&lt;BR /&gt;&lt;BR /&gt;Regards</description>
    <pubDate>Thu, 11 Oct 2007 06:30:36 GMT</pubDate>
    <dc:creator>Oviwan</dc:creator>
    <dc:date>2007-10-11T06:30:36Z</dc:date>
    <item>
      <title>Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084593#M92090</link>
      <description>Looking for a bit of help with a 'simple' script to role some WebSphere logs. I have three servers with multiple logs on each. The path to the logs on each server is different by only one directory name eg:&lt;BR /&gt;&lt;BR /&gt;Server1:/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/SystemOut.log&lt;BR /&gt;&lt;BR /&gt;Server2:/opt/IBM/WebSphere/AppServer/profiles/Dmgr02/logs/dmgr/SystemOut.log&lt;BR /&gt;&lt;BR /&gt;Server3:/opt/IBM/WebSphere/AppServer/profiles/Dmgr03/logs/dmgr/SystemOut.log&lt;BR /&gt;&lt;BR /&gt;I have more than one file on each server, but for the purposes of this I'll keep it simple. &lt;BR /&gt;&lt;BR /&gt;I have a reference file with a list of logs, and I've sumplimented the Dmgr0n with a variable $DMGR. I then have a script that should substitute $DMGR with the actual name, then role the logs. &lt;BR /&gt;&lt;BR /&gt;The script:&lt;BR /&gt;~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;DATE=`date +%b%o`&lt;BR /&gt;WASLOGS=/sysadmin/unix/scripts/puma/WASlogs&lt;BR /&gt;HOST=$1&lt;BR /&gt;&lt;BR /&gt;case $1 in&lt;BR /&gt;Server1)&lt;BR /&gt;                DMGR=Dmgr01&lt;BR /&gt;                ;;&lt;BR /&gt;Server2)&lt;BR /&gt;                DMGR=Dmgr02&lt;BR /&gt;                ;;&lt;BR /&gt;Server3)&lt;BR /&gt;                DMGR=Dmgr03&lt;BR /&gt;                ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;echo $DMGR&lt;BR /&gt;&lt;BR /&gt;for FILE in `cat $WASLOGS` &lt;BR /&gt;do&lt;BR /&gt;        echo $FILE&lt;BR /&gt;        if [ -f $FILE ]&lt;BR /&gt;        then&lt;BR /&gt;                OLDFILE=$FILE.$DATE&lt;BR /&gt;                mv $FILE $OLDFILE 2&amp;gt;&amp;amp;1&lt;BR /&gt;                &amp;gt; $FILE&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;The referenced file contains: /opt/IBM/WebSphere/AppServer/profiles/$DMGR/logs/dmgr/SystemOut.log&lt;BR /&gt;&lt;BR /&gt;The script, when run doesn't recognise the $DMGR in the reference file as a variable, it translates it as a string. &lt;BR /&gt;&lt;BR /&gt;root@Server1:/sysadmin/unix/scripts &amp;gt; ./rolewaslogs.sh Server1&lt;BR /&gt;+ + date +%b%o&lt;BR /&gt;DATE=Oct07&lt;BR /&gt;+ WASLOGS=/sysadmin/unix/scripts/WASlogs&lt;BR /&gt;+ HOST=Server1&lt;BR /&gt;+ DMGR=Dmgr01&lt;BR /&gt;+ echo Dmgr01&lt;BR /&gt;Dmgr01&lt;BR /&gt;+ cat /sysadmin/unix/scripts/WASlogs&lt;BR /&gt;+ [ -f /opt/IBM/WebSphere/AppServer/profiles/$DMGR/logs/dmgr/SystemOut.log ]&lt;BR /&gt;&lt;BR /&gt;Can anyone explain how i can get my script to qualify the variables I'm trying to set in the reference file?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 11 Oct 2007 06:04:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084593#M92090</guid>
      <dc:creator>RobinKing</dc:creator>
      <dc:date>2007-10-11T06:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084594#M92091</link>
      <description>Hey&lt;BR /&gt;&lt;BR /&gt;you could also grep the $WASLOGS file like this:&lt;BR /&gt;&lt;BR /&gt; for FILE in $(grep ${DMGR} $WASLOGS)&lt;BR /&gt;&lt;BR /&gt;then you get only the files which contains $DMGR&lt;BR /&gt;&lt;BR /&gt;hope this helps&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 11 Oct 2007 06:30:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084594#M92091</guid>
      <dc:creator>Oviwan</dc:creator>
      <dc:date>2007-10-11T06:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084595#M92092</link>
      <description>Everyline in the reference file will be a vlid log file, so I won't need to filter them</description>
      <pubDate>Thu, 11 Oct 2007 06:33:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084595#M92092</guid>
      <dc:creator>RobinKing</dc:creator>
      <dc:date>2007-10-11T06:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084596#M92093</link>
      <description>oh sorry misunderstood...&lt;BR /&gt;you can source the WASLOGS file and redirect it like this:&lt;BR /&gt;&lt;BR /&gt;....&lt;BR /&gt;echo $DMGR&lt;BR /&gt;#this will "translate" the ${DMGR} variable in the file&lt;BR /&gt;&lt;BR /&gt;. $WASLOGS &amp;gt;&amp;gt; newlogfile #dot space $WASLOGS&lt;BR /&gt;for FILE in `cat newlogfile`&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;and another thing write the DMGR variable in the WASLOGS file like this ${DMGR} instead of $DMGR&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Oct 2007 06:44:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084596#M92093</guid>
      <dc:creator>Oviwan</dc:creator>
      <dc:date>2007-10-11T06:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084597#M92094</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;You need to use 'eval' to cause the parameter substitution:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;DMGR=server01&lt;BR /&gt;for FILE in `cat WASLOGS`&lt;BR /&gt;do&lt;BR /&gt;    WHICH=$(eval echo ${FILE})&lt;BR /&gt;    echo ${WHICH}&lt;BR /&gt;    if [ -f "${WHICH}" ]; then&lt;BR /&gt;        echo "ok"&lt;BR /&gt;    else&lt;BR /&gt;        echo "no file"&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 11 Oct 2007 07:06:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084597#M92094</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-11T07:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084598#M92095</link>
      <description>Oviman&lt;BR /&gt;&lt;BR /&gt;I've tried that:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo $DMGR&lt;BR /&gt;&lt;BR /&gt;. ${WASLOGS} &amp;gt;&amp;gt; newlog &lt;BR /&gt;echo ${DMGR}&lt;BR /&gt;for FILE in `cat newlog`        &lt;BR /&gt;do&lt;BR /&gt;        if [ -f ${FILE} ]&lt;BR /&gt;        then&lt;BR /&gt;                OLDFILE=${FILE}.${DATE}&lt;BR /&gt;                mv ${FILE} ${OLDFILE} 2&amp;gt;&amp;amp;1&lt;BR /&gt;                &amp;gt; ${FILE}&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;root@hostname:/sysadmin/unix/scripts &amp;gt; cat WASlogs&lt;BR /&gt;/opt/IBM/WebSphere/AppServer/profiles/${DMGR}/logs/dmgr/SystemOut.log&lt;BR /&gt;&lt;BR /&gt;It seems to qualify the variable, but gives the following error:&lt;BR /&gt;&lt;BR /&gt;+ . /sysadmin/unix/scripts/WASlogs&lt;BR /&gt;+ 1&amp;gt;&amp;gt; newlog&lt;BR /&gt;+ /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/SystemOut.log&lt;BR /&gt;./rolewaslogs.sh[35]: /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/SystemOut.log: Execute permission denied.&lt;BR /&gt;+ echo Dmgr01&lt;BR /&gt;Dmgr01&lt;BR /&gt;+ cat newlog</description>
      <pubDate>Thu, 11 Oct 2007 07:08:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084598#M92095</guid>
      <dc:creator>RobinKing</dc:creator>
      <dc:date>2007-10-11T07:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Qualifying variables across files</title>
      <link>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084599#M92096</link>
      <description>James, that worked perfectly! Thanks!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Oct 2007 07:14:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/qualifying-variables-across-files/m-p/4084599#M92096</guid>
      <dc:creator>RobinKing</dc:creator>
      <dc:date>2007-10-11T07:14:12Z</dc:date>
    </item>
  </channel>
</rss>

