<?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: functions in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523106#M701293</link>
    <description>Here is how you can use the stat() in C&lt;BR /&gt;When you use this function it actually returns you a pointer to a structure "stat" which defines all the parameters of a file, below is a simple example which when compiled and run bu passing a file return the inode and the size of the file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;main (argc, argv)&lt;BR /&gt;int argc;&lt;BR /&gt;char *argv[];&lt;BR /&gt;{&lt;BR /&gt;struct stat buf;&lt;BR /&gt;stat(argv[1], &amp;amp;buf);&lt;BR /&gt;&lt;BR /&gt;printf("The file size are: %ld\n", buf.st_size);&lt;BR /&gt;printf("The file inode are: %ld\n", buf.st_ino);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Rajeev&lt;/SYS&gt;&lt;/SYS&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Tue, 12 Apr 2005 21:19:03 GMT</pubDate>
    <dc:creator>Rajeev  Shukla</dc:creator>
    <dc:date>2005-04-12T21:19:03Z</dc:date>
    <item>
      <title>functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523103#M701290</link>
      <description>hi all&lt;BR /&gt;i want to ask about &lt;BR /&gt;how can i use functions like (stat,lstat,..)&lt;BR /&gt;in my script?&lt;BR /&gt;&lt;BR /&gt;i writes scripts using sh and korn?&lt;BR /&gt;when i type any of this commands in prompt &lt;BR /&gt;it return error&lt;BR /&gt;sh:lstat : not found&lt;BR /&gt;&lt;BR /&gt;please explain&lt;BR /&gt;&lt;BR /&gt;thankx&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Apr 2005 10:09:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523103#M701290</guid>
      <dc:creator>kamal_15</dc:creator>
      <dc:date>2005-04-12T10:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523104#M701291</link>
      <description>Strictly speaking stat() and lstat() are system calls and you cannot use them from the shell. Learn C/C++ then you can use them. Now you create a c program that invokes stat() and outputs to stdout and then you could use that command in a shell script.&lt;BR /&gt;&lt;BR /&gt;A much better solution is to use Perl. If has both the stat() and lstat() functions built-in.&lt;BR /&gt;&lt;BR /&gt;You could even do something like this:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;STAT=$(perl -e stat("/tmp"))&lt;BR /&gt;echo "STAT = ${STAT}"&lt;BR /&gt;&lt;BR /&gt;but you would really need to fprmat the stat output to be meaningful too you. &lt;BR /&gt;&lt;BR /&gt;The best answer is to learn Perl and do your scripting in it.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Apr 2005 10:19:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523104#M701291</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-04-12T10:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523105#M701292</link>
      <description>I really should give you a little better example in Perl:&lt;BR /&gt;perl -e  '@x = stat("/tmp"); foreach $x (@x) {print $x," ";} print "\n";'&lt;BR /&gt;&lt;BR /&gt;This is untested but it should at least give you the fields separated by a space. You should note that the times are epoch seconds so you still have some work to do. Mode would be more meaningful is printed in octal but I 'll leave all that to you.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Apr 2005 14:30:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523105#M701292</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-04-12T14:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: functions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523106#M701293</link>
      <description>Here is how you can use the stat() in C&lt;BR /&gt;When you use this function it actually returns you a pointer to a structure "stat" which defines all the parameters of a file, below is a simple example which when compiled and run bu passing a file return the inode and the size of the file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;&lt;BR /&gt;main (argc, argv)&lt;BR /&gt;int argc;&lt;BR /&gt;char *argv[];&lt;BR /&gt;{&lt;BR /&gt;struct stat buf;&lt;BR /&gt;stat(argv[1], &amp;amp;buf);&lt;BR /&gt;&lt;BR /&gt;printf("The file size are: %ld\n", buf.st_size);&lt;BR /&gt;printf("The file inode are: %ld\n", buf.st_ino);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Rajeev&lt;/SYS&gt;&lt;/SYS&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 12 Apr 2005 21:19:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/functions/m-p/3523106#M701293</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2005-04-12T21:19:03Z</dc:date>
    </item>
  </channel>
</rss>

