2 Replies Latest reply on Aug 21, 2006 8:34 AM by susan daane

    perl NSH module scripting - bl 6.3.2

      Has anyone had problems (or better yet, NOT had problems) writing files with the perl NSH module? I have been trying for a week to write a large file with long lines to the appserver, and to a remote host, with little success. Does the following code work on your server? (example courtesy of Sung Koo):


      use NSH;

      $appserver = "";

      $portfile = "tmp/portfile";

      @lines = ("my\n", "name\n", "is\n", "nobody\n", "That weapon will replace your tongue. You will speak through it. And your poetry will now be written with blood. -- Dead Man\n") ;


      NSH::chdir("//$appserver") || print "cant cd to remote host:$!\n";

      NSH::system("rm -f /$portfile");



      $fd0 = NSH::open("/$portfile","w",0777) || die "can't open $filename for writing: $!" ;


      foreach $line (@lines)




      Thank you in advance, Susan

        • 1. Re: perl NSH module scripting - bl 6.3.2
          Mark Jeffery



          Are you able to do anything with the perl module?


          What platform are you using, and what platform is your app server?


          I have often written things without using the NSH module, and exec'ing nsh. For example, the following opens up a remote file:


          open(HL,"nsh -c \"cat $hostlist\"|") ||

          die "Couldn't open $hostlist : $!\n";

          while () {


          if ($_ =~ /^(/w/-/.+)/) {

          push @hosts,$1;



          close HL;



          • 2. Re: perl NSH module scripting - bl 6.3.2

            The perl module works otherwise. The appserver is Solaris 9, and I'm running nsh from a windows 2000 machine. I've tried opening files on Solaris 9 and 10 remote hosts.


            I can write to the file by doing echos in a loop (NSH::system("echo $line >> file")), but many of the lines exceed the 255-char limit that NSH has. Worse, all of the lines don't make it into the file - the different NSH::system lines apparently get executed in random order and step on each other. It just seems crazy that this is so tough - that it's so hard to write to a remote file. We will need to do a lot of it.


            Thanks for getting back to me. I'm still looking for a solution!