- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- List of Files and FS Sizes
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 01:39 AM
06-20-2007 01:39 AM
ls -ld /a????/amfp*
But I require only these names and their filesystem's space alloted, used, available. Also, I would like to have this info from several ssh servers.
Please advice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:09 AM
06-20-2007 02:09 AM
Re: List of Files and FS Sizes
Are amfp* directories or files?
Regards
Andrew Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:20 AM
06-20-2007 02:20 AM
Re: List of Files and FS Sizes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:23 AM
06-20-2007 02:23 AM
Re: List of Files and FS Sizes
echo "Enter Linux Server Name (e.g. l57)"
read serv
case "$serv" in
l57)
ssh $serv "for i in `cat 57.txt`
do
df -k $i
done" >> 57.out
;;
l58)
;;
l59)
;;
*)
echo "Bad command, your choices are: Linux Server Names"
;;
esac
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:34 AM
06-20-2007 02:34 AM
Re: List of Files and FS Sizes
If they are Linux servers you will need to change the bdf to df -k
For ssh then try the following variation:
ssh $serv "for id in `ls -d /a\?\?\?\?/amfp\*` ; do if [ -d \$id ] ; then df -k \$id; fi ; done"
Please note I have escaped the wild cards and dollar symbols to prevent them from being evaluated by the local shell.
HTH
Andrew Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:35 AM
06-20-2007 02:35 AM
Re: List of Files and FS Sizes
Regards
Andrew Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:47 AM
06-20-2007 02:47 AM
Re: List of Files and FS Sizes
for serv_cnt in `cat /home/mfgeb/pp/serv.txt`
do
echo "===[ Directory Size for Server: $serv_cnt ]==="
ssh $serv "for id in \`ls -d /a\?\?\?\?/amfp\*\` ;
do
if [ -d \$id ] ;
then df -k \$id;
fi ;
done" >> {serv}.out
done >> dbsize.lst
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 02:51 AM
06-20-2007 02:51 AM
Re: List of Files and FS Sizes
I am having some issues with my testing which I think are shell specific with regards to what I need escape.
Regards
Andrew Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 05:18 AM
06-20-2007 05:18 AM
Re: List of Files and FS Sizes
- change to single quotes will make life easier.
- the remote shell will expand the filename pattern by itself: no need for 'ls -d'
- in this situation, I would send the output to a file AND terminal.
- you mixed up variable names ($serv, $serv_cnt)
- watch carefully the end of my quoting: the filename will be expanded by the local shell but used at the remote site.
Calling from a POSIX shell, I suggest:
for serv in $(do
print "===[ Directory Size for Server: $serv ]==="
ssh -n $serv 'for id in /a????/amfp*; do
[ -d $id ] && df -k $id; done | tee '${serv}.out
done | tee dbsize.lst
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2007 09:18 AM
06-20-2007 09:18 AM
Re: List of Files and FS Sizes
Thanks for your help. I know this isn't my post but if I may ask two questions about your script.
Firstly I don't understand the location of your closing single quote. I would have thought the quote should be after the done before the first pipe symbol.
Secondly I had got most of the way as your script with my later versions, the only difficulty now is how would I do it if I want the remote shell to expand the wildcards and not the local shell?
If I do escape them then the escapes are carried over to the remote shell and if I don't then the local shell expands them.
The ugly work around was to do something like this:
ssh -n $serv 'files=`eval eval echo "/a\?\?\?\?/amfp\*"` ;for id in `echo $files` ; do [ -d $id ] && df -k $id; done | tee '${serv}.out done | tee dbsize.lst
However since this is Linux (I'm assuming RedHat here) a much safer way would be to use the /etc/mtab file which already lists the mounted filesystems.
Then you can replace the above code with:
ssh -n $serv 'for id in `cat /etc/mtab | cut -f2 -d" " | grep "/a..../ampf.*"` ; do df -k $id ; done ' | tee ${serv}.out done | tee dbsize.lst
Regards
Andrew Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 04:02 AM
06-21-2007 04:02 AM
Re: List of Files and FS Sizes
this is for Andrew, though others might be interested as well :-)
Let's look at this construction:
ssh -n $serv 'for id in /a????/amfp*; do
[ -d $id ] && df -k $id; done | tee '${serv}.out
1) The local shell expands the value of the variable 'serv'
2) ssh gets ONE execution string, consisting of the part between the single quotes - which will be left unmodified by the local shell - concatenated with the values of the expanded shell variable and the suffix: To make this work, no space is allowed between the single quote and the '$serv', neither may the variable contain a space character!
3) The remote shell spawned by the ssh command will now parse the command string, and do whát has to be done:
- look for quoting (none found!)
- do filename expansion of /a????/amfp* !!
...
I assumed when reading the remarks of the thread creator, that the file $serv.out should be created at the remote site.
To get that file locally is easier, of course.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 04:09 AM
06-21-2007 04:09 AM
Re: List of Files and FS Sizes
I have one more doubt: In below script, IF i wish to grep some value, Its not coming at all.
for serv_cnt in `cat /home/mfgeb/pp/serv.txt`
do
ssh $serv_cnt "for id in \`cat arra.lst\` ;
do
grep \$id /home/ppp?.st ;
done" >> inner.out
done
The issue is that grep isnt able to understand $id within ssh's for loop. Am i missing something?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 04:18 AM
06-21-2007 04:18 AM
Re: List of Files and FS Sizes
read my replies carefully - I see double quotes in your command, so $id will be expanded locally.
Use single quotes for the ssh command string!
mfG Peter
PS: Better reopen this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 04:32 AM
06-21-2007 04:32 AM
Re: List of Files and FS Sizes
a300sl57:/home/mfgeb/pp/extents> ./ext_grp1.sh
+++ cat /home/mfgeb/pp/extents/serv.txt
++ ssh a300sl57 'for id in \`cat /home/mfgeb/pp/extents/extlist.lst\` ;
do
grep \$id /a???1/amfp???p/a??????p.st;
done'
++ ssh a300sl58 'for id in \`cat /home/mfgeb/pp/extents/extlist.lst\` ;
do
grep \$id /a???1/amfp???p/a??????p.st;
done'
a300sl57:/home/mfgeb/pp/extents> more ext_grp1.sh
set -ax
for srv in `cat /home/mfgeb/pp/extents/serv.txt`
do
ssh $srv 'for id in \`cat /home/mfgeb/pp/extents/extlist.lst\` ;
do
grep \$id /a???1/amfp???p/a??????p.st;
done' >> out.out2
done
a300sl57:/home/mfgeb/pp/extents>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 07:41 AM
06-21-2007 07:41 AM
Re: List of Files and FS Sizes
the modified version of your previous reply:
for serv_cnt in `cat /home/mfgeb/pp/serv.txt`
do
ssh $serv_cnt 'for id in `cat arra.lst` ;
do
grep $id /home/ppp?.st ;
done' >> inner.out
done
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2007 08:32 PM
06-21-2007 08:32 PM