Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000577.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: Rexec</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000576.html" title="Redirecting on ErrorDocument" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000578.html" title="Rexec" />
17
18    
19
20    
21
22    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
23 </head>
24 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
25    <div id="container">
26       <div id="container-inner" class="pkg">
27
28          <div id="banner">
29             <div id="banner-inner" class="pkg">
30                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
31                <h2 id="banner-description">Searchable status reports and work log</h2>
32             </div>
33          </div>
34
35          <div id="pagebody">
36             <div id="pagebody-inner" class="pkg">
37                <div id="alpha">
38                   <div id="alpha-inner" class="pkg">
39
40                      <p class="content-nav">
41                         <a href="http://defaria.com/blogs/Status/archives/000576.html">&laquo; Redirecting on ErrorDocument</a> |
42                         <a href="http://defaria.com/blogs/Status/">Main</a>
43                         | <a href="http://defaria.com/blogs/Status/archives/000578.html">Rexec &raquo;</a>
44                      </p>
45
46                      <a id="a000577"></a>
47                      <div class="entry" id="entry-577">
48                         <h3 class="entry-header">Rexec</h3>
49                         <div class="entry-content">
50                            <div class="entry-body">
51                               <ul>
52   <li>Fixed bug in gpdb_add_project.pl</li>
53
54   <li>Met about MultiSite Hardening Daemon (MSHD)</li>
55 </ul>
56                            </div>
57                            <div id="more" class="entry-more">
58                               <h2>Rexec</h2>
59
60 <p>The gpdb_add_project.pl script utilizes rsh to log into remote sites to execute and otherwise gather data from other sites (Actually it uses rsh locally too but that's another blog entry!). It does this with code like this:</p>
61
62 <div class=code><pre>
63 unless ($site_registry_handle->open("rsh $siteHash{$siteName} -n cat $syncReg |"))  {
64    print ("Can not open rsh $siteHash{$siteName} -n cat $syncReg |.\n");
65    exit;
66 }
67 </pre></div>
68
69 <p>The problem is that the above code will not work. What is returned from the open call here is whether or not the rsh command worked - not whether or not the cat command worked! Indeed open of a pipe returns little - it's the close of the pipe that's going to return the status of the rsh! The status of the cat in this case is never returned. And in this case it was failing. There is no real reliable method for getting the status of the cat command except perhaps to process the remote session using expect or Perl/Expect.</p>
70
71 <p>Since we expect the cat to work and to return lines and because there is a specific format for the first line, I implemented the following:</p>
72
73 <div class=code><pre>
74 sub GetDSRegFile {
75   my $file      = shift;
76   my $server    = shift;
77
78   my @lines;
79
80   if ($server) {
81     @lines = `rsh $server -n cat $file`;
82
83     return undef if $?;
84   } else {
85     @lines = `cat $file`;
86   } # if
87
88   if ($lines [0] and $lines [0] !~ /\#\# SYNC_VERSION 1\.0/) {
89     return undef;
90   } else {
91     return @lines;
92   } # if
93 } # GetDSRegFile
94 </pre></div>
95
96 <p>This solves the problem for this particular case. However this script uses this invalid technique for many other "remote calls" and has potential for error.</p>
97
98
99                            </div>
100                         </div>
101                         <p class="entry-footer">
102                            <span class="post-footers">Posted by  on October  5, 2006  3:21 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000577.html">Permalink</a>
103                         </p>
104                      </div>
105
106                      
107
108                      
109                   </div>
110                </div>
111             </div>
112          </div>
113       </div>
114    </div>
115 </body>
116 </html>