LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 08-27-2013, 09:38 AM   #1
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Rep: Reputation: 1
-:::Don't understand this small script:::-


Hi Guys,

I don't understand this script,

What does this line " cd `ls |grep -v tar`/disks" here????


Code:
-bash-3.00$ /usr/local/bin/sudo cat /users/sysmgr/ios
Password:
#!/usr/bin/bash

cd /opt/SUNWexplo/output/
cd `ls  |grep -v tar`/disks
echo `pwd`
cp iostat_-E.out /users/sysmgr/ionew
diff /users/sysmgr/ionew/iostat_-E.out  /users/sysmgr/ioold/iostat_-E.out >/users/sysmgr/iodiff
if [ -s /users/sysmgr/iodiff ]
then
echo
else
echo `pwd`
cat /dev/null >iostat_-E.out
cd /opt/SUNWexplo/output
echo `pwd`
rm -f `ls |grep explorer.844d540d.server1|grep tar`
h=`ls |grep -v tar`
tar cvf  $h.tar $h
gzip $h.tar
fi
cp /users/sysmgr/ionew/iostat_-E.out /users/sysmgr/ioold


-bash-3.00$
it showing me this errors:-
Code:
Your "cron" job on server1
/usr/local/bin/sudo /users/sysmgr/ios  #HD404710

produced the following output:

/opt/SUNWexplo/output/explorer.844d540d.server1-2013.08.26.00.00
cp: cannot access iostat_-E.out
/opt/SUNWexplo/output/explorer.844d540d.server1-2013.08.26.00.00
/opt/SUNWexplo/output
tar: explorer.844d540d.server1-2013.08.26.00.00: Is a directory
gzip: explorer.844d540d.server1-2013.08.26.00.00 is a directory -- ignored
gzip: iostat_-E.out.gz already has .gz suffix -- unchanged
gzip: stderr.21762.tar: No such file or directory

EDIT:--
This what I have in /opt/SUNWexplo/output/
Code:
-bash-3.00$ cd /opt/SUNWexplo/output/
-bash-3.00$ ls -la
total 12
drwxr-xr-x   3 root     bin          512 Aug 27 14:50 .
drwxr-xr-x  12 root     bin          512 Jul 31 12:25 ..
-r--------   1 root     root          11 Jul 29 02:06 .explastrun
drwx------  20 root     root         512 Aug 27 14:50 explorer.844d540d.amspdmbep31-2013.08.27.07.02
-rw-r--r--   1 root     root          34 Aug 19 02:45 iostat_-E.out.gz
-rw-------   1 root     root          88 Jun 25 10:30 stderr.21762
-bash-3.00$

Last edited by manalisharmabe; 08-27-2013 at 09:48 AM.
 
Old 08-27-2013, 09:46 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Lets see...

cd `ls |grep -v tar`/disks

so its trying to change directory to: (something without 'tar' in it)/disks. it depends on where you run this, whether it will work or not.

pseudo:

ls current directory
grep for names without tar in it
append it to /disks
cd to (result)/disks
 
1 members found this post helpful.
Old 08-27-2013, 09:52 AM   #3
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by szboardstretcher View Post
Lets see...

cd `ls |grep -v tar`/disks

so its trying to change directory to: (something without 'tar' in it)/disks. it depends on where you run this, whether it will work or not.

pseudo:

ls current directory
grep for names without tar in it
append it to /disks
cd to (result)/disks
Does it mean disks is created at "/" ?
 
Old 08-27-2013, 09:54 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
eh.. let me see here..

cd /opt/SUNWexplo/output/; cd `ls |grep -v tar`/disks

So this 'disks' directory is a subdirectory somewhere in /opt/SUNWexplo/output.

so go there, then try a:

find . -name disks

If you'd like to know where the disks directory is.
 
Old 08-27-2013, 10:02 AM   #5
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by szboardstretcher View Post
eh.. let me see here..

cd /opt/SUNWexplo/output/; cd `ls |grep -v tar`/disks

So this 'disks' directory is a subdirectory somewhere in /opt/SUNWexplo/output.

so go there, then try a:

find . -name disks

If you'd like to know where the disks directory is.
no its not there, disks is not there.
Code:
-bash-3.00$ ls -la disks
disks: No such file or directory
-bash-3.00$ pwd
/opt/SUNWexplo/output
-bash-3.00$

Last edited by manalisharmabe; 08-27-2013 at 10:03 AM.
 
Old 08-27-2013, 10:06 AM   #6
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
This how it produces output when it runs well on other server.

Code:
Your "cron" job on server2
/usr/local/bin/sudo /users/sysmgr/ios    # HD 404710

produced the following output:

/opt/SUNWexplo/output/explorer.833c0503.server2-2013.08.26.00.00/disks
/opt/SUNWexplo/output/explorer.833c0503.server2-2013.08.26.00.00/disks
/opt/SUNWexplo/output
a explorer.833c0503.server2-2013.08.26.00.00/ 0K
a explorer.833c0503.server2-2013.08.26.00.00/rda/ 0K
a explorer.833c0503.server2-2013.08.26.00.00/rda/RDA.log 6K
a explorer.833c0503.server2-2013.08.26.00.00/rda/collect/ 0K
a explorer.833c0503.server2-2013.08.26.00.00/rda/collect/EXPLORER_XPLR_ptch_z_global.txt 189K
a explorer.833c0503.server2-2013.08.26.00.00/rda/collect/EXPLORER_XPLR_pkg_z_global.txt 1545K
a explorer.833c0503.server2-2013.08.26.00.00/rda/collect/EXPLORER_XPLR_cfg_z_global.txt 1645K
Above are just starting few lines of big output of that script.

Last edited by manalisharmabe; 08-27-2013 at 10:07 AM.
 
Old 08-27-2013, 11:05 AM   #7
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
Quote:
cp iostat_-E.out /users/sysmgr/ionew

cp: cannot access iostat_-E.out
Result of a buggy script... you should always make sure the file or dir exists and has sufficient read and write permissions prior to use them anywhere in the script.
So above cp erroris because of insufficient permissions on the file.

Quote:
tar: explorer.844d540d.server1-2013.08.26.00.00: Is a directory
gzip: explorer.844d540d.server1-2013.08.26.00.00 is a directory -- ignored
gzip: iostat_-E.out.gz already has .gz suffix -- unchanged
gzip: stderr.21762.tar: No such file or directory
Again not checked for a file and nor for existing archive.

EDIT:

assuming you dont have sufficient permisions to change the script... so for this to work fine you have to apply correct permissions on the file "*.out" and and rename the .gz file to something else. That should be it.

Last edited by SAbhi; 08-27-2013 at 11:11 AM.
 
1 members found this post helpful.
Old 08-28-2013, 01:10 AM   #8
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
[QUOTE=SAbhi;5016930]Result of a buggy script... you should always make sure the file or dir exists and has sufficient read and write permissions prior to use them anywhere in the script.


NO. this scripts works fine on other solaris 10 server.
this script has started giving errors when we upgraded Sun Explorer version from 7.3 to 8.0. on this machine.

Last edited by manalisharmabe; 08-28-2013 at 01:16 AM.
 
Old 08-28-2013, 02:44 AM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Then downgrade explorer to 7.3 or upgrade your script to something that work with explorer 8.0.
If there is no such update, find out the people who wrote the script and ask them for support.
If not available, figure out why and what something changed in the directory layout between the explorer releases.
 
Old 08-28-2013, 10:47 AM   #10
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
[QUOTE=manalisharmabe;5017257]
Quote:
Originally Posted by SAbhi View Post
NO. this scripts works fine on other solaris 10 server.
this script has started giving errors when we upgraded Sun Explorer version from 7.3 to 8.0. on this machine.

Actually the script is sure a buggy script.. reasons i have already mentioned in the last post... it was working fine on other servers because they have the required file and permissions set already and hence it executed.. while when you upgraded a server and it dont have the required sets of permissions and already a archive present, the script should have statements checking that..

for the solution i already have mentioned in EDIT section of last comment.
 
Old 08-28-2013, 03:51 PM   #11
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
that script is .. bad and not as in good.


Warning:
I have never used solaris.
The below is Untested...even on gnu/linux
may use 'features' not available to you
no real error checking/reporting..

Code:
#!/usr/bin/bash

Output=/opt/SUNWexplo/output
iostat_err=${Output}/*/disks/iostat_-E.out
LastIOStat=${Output}/.LastIOStat

# initial LastIOStat
[[ ! -e $LastIOStat ]] \
  && ( echo "ffffffffffffffffffffffffffffffff  ${iostat_err}" > $LastIOStat )

function Archive() {
Tar=${Output}/*/
TarExt=.tar.gz

tar avcf ${Tar/%\//$TarExt} -C ${Output}/ */ 
return $?
}

function Laststat(){
md5sum ${iostat_err} > ${LastIOStat}
return $?
}

[[ -s "${iostat_err}" ]] \
   && (
     md5sum --status -c $LastIOStat || ( Archive && Laststat );exit $?
   ) || exit 0
fi
Notes:
  • tar will overwrite existing archive ( unless you pass append arg.), so no need to delete
  • The above assumes your tar can compress, and is capable of automagical determination of compression program
  • using md5sum to determine if iostat_-E.out changed ( so you get to keep it )
  • No real error checks in above script
  • Warning: it looks like you may have multiple explorer.*.server*, if that is the case then the original nor the above 'deal' with that
  • will do nothing until you determine correct location of iostat_-E.out
    ( or you get some actual IO errors )

Last edited by Firerat; 08-28-2013 at 03:59 PM.
 
Old 08-31-2013, 07:23 AM   #12
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
-bash-3.00$ cd /opt/SUNWexplo/output/
-bash-3.00$ ls -la
total 12
drwxr-xr-x 3 root bin 512 Aug 27 14:50 .
drwxr-xr-x 12 root bin 512 Jul 31 12:25 ..
-r-------- 1 root root 11 Jul 29 02:06 .explastrun
drwx------ 20 root root 512 Aug 27 14:50 explorer.844d540d.amspdmbep31-2013.08.27.07.02
-rw-r--r-- 1 root root 34 Aug 19 02:45 iostat_-E.out.gz
-rw------- 1 root root 88 Jun 25 10:30 stderr.21762
-bash-3.00$

Hi Guys,
I changed bash to ksh, as it was initially.
I removed this two files:-
Code:
-rw-r--r--   1 root     root          34 Aug 31 14:14 iostat_-E.out.gz
-rw-------   1 root     root          88 Jun 25 10:30 stderr.21762
from above location and script just ran well , without any error.

I just compared the files with other servers where this scripts runs well and these 2 files were not there.

Hopefully , I think I have got the solution now.

Thanks a lot for all your replies.

Last edited by manalisharmabe; 08-31-2013 at 07:41 AM.
 
Old 08-31-2013, 10:26 AM   #13
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
Thats exactly what you were told in my last post.
 
Old 09-17-2013, 12:10 AM   #14
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
Hi Guys,

I Just reopened this thread due to one query.

Whenever i run this comand /usr/local/bin/sudo /users/sysmgr/ios on command line only


this line /opt/SUNWexplo/output/explorer.833b0e87.server1-2013.09.16.00.00/disks
get produced but when I again run it, it get executed fully like this:-

Code:
opt/SUNWexplo/output/explorer.833c0503.server1-2013.09.16.00.00/disks
/opt/SUNWexplo/output/explorer.833c0503.server1-2013.09.16.00.00/disks
/opt/SUNWexplo/output
a explorer.833c0503.server1-2013.09.16.00.00/ 0K
a explorer.833c0503.server1-2013.09.16.00.00/rda/ 0K
a explorer.833c0503.server1-2013.09.16.00.00/rda/RDA.log 6K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/ 0K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_ptch_z_global.txt 189K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_pkg_z_global.txt 1545K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_cfg_z_global.txt 1646K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00006_sysconfig_lutab.lin 1K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00007_sysconfig_drv_aac_conf.lin 1K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00008_sysconfig_drv_aggr_conf.lin 1K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00009_sysconfig_drv_arp_conf.lin 1K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00010_sysconfig_drv_audio1575_conf.lin 2K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00011_sysconfig_drv_audiocs_conf.lin 2K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00012_sysconfig_drv_audioens_conf.lin 2K
a explorer.833c0503.server1-2013.09.16.00.00/rda/collect/EXPLORER_XPLR_R00013_sysconfig_drv_audiots_conf.lin 2K


In first attempt this is how it attempts in mail in first attempt:-

Code:
Your "cron" job on server1
/usr/local/bin/sudo /users/sysmgr/ios
produced the following output:
/opt/SUNWexplo/output/explorer.833b0e87.server1-2013.09.16.00.00/disks

What could be the problem that it does not hget executed in first run?

Does it mean that it does not send system information to Sun Explorer Portal?

Well, After first run I did check /opt/SUNWexplo/output folder but nothing speacial get created there.

Please advise.

Last edited by manalisharmabe; 09-17-2013 at 12:13 AM.
 
Old 09-17-2013, 12:43 AM   #15
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
Manali,

first of all whenever you are posting a new issue, use a new thread.

Quote:
Whenever i run this comand /usr/local/bin/sudo /users/sysmgr/ios on command line only
i cant say i understood what you posted...

are you running this command command as a cron job or in a terminal seperately ???
if from a cron share the con entry,
also share

Code:
ls -l /opt/SUNWexplo/output/explorer.833c0503.server1-2013.09.16.00.00/disks

Last edited by SAbhi; 09-17-2013 at 12:45 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash script - don't understand error itsnew2me Linux - Newbie 4 11-24-2012 07:57 AM
don't understand budbaker44 Linux - Newbie 2 09-02-2009 12:30 PM
Don't Understand melp57 Linux - Newbie 6 11-13-2007 07:14 PM
I don't understand Coimbra Linux - Newbie 2 05-22-2007 05:38 AM
i don't understand... humanveal Linux - Software 17 05-20-2003 03:24 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 05:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration