<?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 Converting Kshell to C language in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-kshell-to-c-language/m-p/3491304#M214950</link>
    <description>I have gotten this written in korn shell, can anyone give me some guides onto how to covert this to C language. I am particularly interested in how to move files efficiently using C under shell environment. :&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;# -- Date initialisation --&lt;BR /&gt;YY=`date +%Y`&lt;BR /&gt;MM=`date +%m`&lt;BR /&gt;DD=`date +%d`&lt;BR /&gt;HH=`date +%H`&lt;BR /&gt;MI=`date +%M`&lt;BR /&gt;SS=`date +%S`&lt;BR /&gt;&lt;BR /&gt;# -- Files &amp;amp; Directories Initialisation --&lt;BR /&gt;DIR=/users/tester/temp&lt;BR /&gt;SCP=$DIR/T1&lt;BR /&gt;OCP=$DIR/Temp&lt;BR /&gt;FIL=$DIR/file.txt&lt;BR /&gt;OFL=$DIR/file_old.txt&lt;BR /&gt;NFL=$DIR/file_new.txt&lt;BR /&gt;LOG=$DIR/events.txt&lt;BR /&gt;&lt;BR /&gt;TM1=$DIR/tmp1.txt&lt;BR /&gt;TM2=$DIR/tmp2.txt&lt;BR /&gt;&lt;BR /&gt;#Check file modification status&lt;BR /&gt;ls -lt $FIL &amp;gt; $NFL&lt;BR /&gt;diff $NFL $OFL &amp;gt; $TM1&lt;BR /&gt;wc -l $TM1 &amp;gt; $TM2&lt;BR /&gt;No=`awk '{ print $1 }' $TM2`&lt;BR /&gt;cp $NFL $OFL&lt;BR /&gt;#NOW=`date`&lt;BR /&gt;if [ $No -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;        #-- Log event --&lt;BR /&gt;        echo "Change in Tester Deskew file detected, program ran on $YY$MM$DD at $HH$MI$SS""hrs" &amp;gt;&amp;gt; $LOG&lt;BR /&gt;        echo "file modified on $NOW"&lt;BR /&gt;        cp $SCP/* $OCP&lt;BR /&gt;        rm -f $SCP/*&lt;BR /&gt;&lt;BR /&gt;# -- Housekeeping --&lt;BR /&gt;&lt;BR /&gt;if [ -f $TM1 ]&lt;BR /&gt;then&lt;BR /&gt;        rm $TM1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -f $TM2 ]&lt;BR /&gt;then&lt;BR /&gt;        rm $TM2&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -f $NFL ]&lt;BR /&gt;then&lt;BR /&gt;        rm $NFL&lt;BR /&gt;fi&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Feb 2005 19:39:36 GMT</pubDate>
    <dc:creator>Henry Chua</dc:creator>
    <dc:date>2005-02-22T19:39:36Z</dc:date>
    <item>
      <title>Converting Kshell to C language</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-kshell-to-c-language/m-p/3491304#M214950</link>
      <description>I have gotten this written in korn shell, can anyone give me some guides onto how to covert this to C language. I am particularly interested in how to move files efficiently using C under shell environment. :&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;# -- Date initialisation --&lt;BR /&gt;YY=`date +%Y`&lt;BR /&gt;MM=`date +%m`&lt;BR /&gt;DD=`date +%d`&lt;BR /&gt;HH=`date +%H`&lt;BR /&gt;MI=`date +%M`&lt;BR /&gt;SS=`date +%S`&lt;BR /&gt;&lt;BR /&gt;# -- Files &amp;amp; Directories Initialisation --&lt;BR /&gt;DIR=/users/tester/temp&lt;BR /&gt;SCP=$DIR/T1&lt;BR /&gt;OCP=$DIR/Temp&lt;BR /&gt;FIL=$DIR/file.txt&lt;BR /&gt;OFL=$DIR/file_old.txt&lt;BR /&gt;NFL=$DIR/file_new.txt&lt;BR /&gt;LOG=$DIR/events.txt&lt;BR /&gt;&lt;BR /&gt;TM1=$DIR/tmp1.txt&lt;BR /&gt;TM2=$DIR/tmp2.txt&lt;BR /&gt;&lt;BR /&gt;#Check file modification status&lt;BR /&gt;ls -lt $FIL &amp;gt; $NFL&lt;BR /&gt;diff $NFL $OFL &amp;gt; $TM1&lt;BR /&gt;wc -l $TM1 &amp;gt; $TM2&lt;BR /&gt;No=`awk '{ print $1 }' $TM2`&lt;BR /&gt;cp $NFL $OFL&lt;BR /&gt;#NOW=`date`&lt;BR /&gt;if [ $No -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;        #-- Log event --&lt;BR /&gt;        echo "Change in Tester Deskew file detected, program ran on $YY$MM$DD at $HH$MI$SS""hrs" &amp;gt;&amp;gt; $LOG&lt;BR /&gt;        echo "file modified on $NOW"&lt;BR /&gt;        cp $SCP/* $OCP&lt;BR /&gt;        rm -f $SCP/*&lt;BR /&gt;&lt;BR /&gt;# -- Housekeeping --&lt;BR /&gt;&lt;BR /&gt;if [ -f $TM1 ]&lt;BR /&gt;then&lt;BR /&gt;        rm $TM1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -f $TM2 ]&lt;BR /&gt;then&lt;BR /&gt;        rm $TM2&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ -f $NFL ]&lt;BR /&gt;then&lt;BR /&gt;        rm $NFL&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 19:39:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-kshell-to-c-language/m-p/3491304#M214950</guid>
      <dc:creator>Henry Chua</dc:creator>
      <dc:date>2005-02-22T19:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Kshell to C language</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-kshell-to-c-language/m-p/3491305#M214951</link>
      <description>To me, it appears that the job you want to do is &lt;BR /&gt;best handled by using shell script. But if you must &lt;BR /&gt;write a C program for this, here are the library &lt;BR /&gt;routines you should be looking at:&lt;BR /&gt;&lt;BR /&gt;Date initialization: see library routines &lt;BR /&gt;gettimeofday(2), time(2), ctime(3C) and related &lt;BR /&gt;functions (all listed in the manpage of ctime(3C)).&lt;BR /&gt;&lt;BR /&gt;File modification status: Should use fstat(2) call. See &lt;BR /&gt;the manpage for more details. Structure stat &lt;BR /&gt;(defined in sys/stat.h) stores the access details of &lt;BR /&gt;the files. Use difftime(3C) routine for time &lt;BR /&gt;difference.&lt;BR /&gt;&lt;BR /&gt;Log event: If you want to log to /var/adm/syslog,&lt;BR /&gt;then use syslog(3C).&lt;BR /&gt;&lt;BR /&gt;Housekeeping: Use link(2), unlink(2) to copy and &lt;BR /&gt;remove files.&lt;BR /&gt;&lt;BR /&gt;Does that answer what you are looking for?&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 20:35:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-kshell-to-c-language/m-p/3491305#M214951</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-02-22T20:35:29Z</dc:date>
    </item>
  </channel>
</rss>

