I've been trying to install and run a vagrant instance that brings up a CentOS 7 VM. Ideally i would then be able to use ansible to provision the VM with software.
Unfortunately i keep getting this error whenever i try to bring vagrant up:
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.
Could not find the X.Org or XFree86 Window System, skipping.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> default: Checking for guest additions in VM...
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/platform.rb:115:in `cygwin_path': undefined method `gsub!' for nil:NilClass (NoMethodError)
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/synced_folders/rsync/helper.rb:54:in `rsync_single'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/synced_folders/rsync/synced_folder.rb:48:in `block in enable'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/synced_folders/rsync/synced_folder.rb:47:in `each'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/synced_folders/rsync/synced_folder.rb:47:in `enable'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/synced_folders.rb:93:in `block in call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/synced_folders.rb:90:in `each'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/synced_folders.rb:90:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/synced_folders/nfs/action_cleanup.rb:19:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/prepare_nfs_valid_ids.rb:12:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:49:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/env_set.rb:19:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/provision.rb:80:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:15:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/set_name.rb:50:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/call.rb:53:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/call.rb:53:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/call.rb:53:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/box_check_outdated.rb:78:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/match_mac_address.rb:19:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/discard_state.rb:15:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/import.rb:74:in `import'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/import.rb:13:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb:17:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/prepare_clone.rb:15:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/customize.rb:40:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/call.rb:53:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/handle_box.rb:56:in `call' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builtin/call.rb:53:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/machine.rb:227:in `action_raw'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/machine.rb:202:in `block in action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/environment.rb:631:in `lock'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/machine.rb:188:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/machine.rb:188:in `action'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.0/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
C:\Users\tdias\Desktop\Vagrant>
I've tried uninstalling and reinstalling it, but it hasn't worked. I checked the file mentioned and found this:
# This takes any path and converts it from a Windows path to a
# Cygwin or msys style path.
#
# #param [String] path
# #return [String]
def cygwin_path(path)
begin
# We have to revert to the old env
# path here, otherwise it looks like
# msys2 ends up using the wrong cygpath
# binary and ends up with a `/cygdrive`
# when it doesn't exist in msys2
original_path_env = ENV['PATH']
ENV['PATH'] = ENV['VAGRANT_OLD_ENV_PATH']
cygpath = Vagrant::Util::Which.which("cygpath")
cygpath.gsub!("/", '\\')
process = Subprocess.execute(
cygpath, "-u", "-a", path.to_s)
return process.stdout.chomp
rescue Errors::CommandUnavailableWindows => e
# Sometimes cygpath isn't available (msys). Instead, do what we
# can with bash tricks.
process = Subprocess.execute(
"bash",
"--noprofile",
"--norc",
"-c", "cd #{Shellwords.escape(path)} && pwd")
return process.stdout.chomp
ensure
ENV['PATH'] = original_path_env
end
end
Does anyone know how to fix?
This line is your problem:
cygpath.gsub!("/", '\\')
You are trying to change all "/" in your string with '\', but there is no "/" in your text, if you use gsub insted of gsub!, you will not get this error.
Related
I have the following code which works fine with an AWS instance with Ubuntu but not with Fedora.
#!/bin/perl
use Net::FTP;
use Net::SMTP;
use warnings;
use POSIX qw(strftime);
my $now_string = localtime;
my $date = strftime "%d/%d/%Y", localtime;
my $checkdate = strftime "%d/%b/%Y", localtime;
my $username = "apikey";
my $passwd = "REDACTED";
my $from = 'Reports <reports#redacted.com';
my $smtphost = 'smtp.sendgrid.net';
my $smtp = Net::SMTP->new($smtphost, Port => 587, Debug => 1);
$smtp->auth($username,$passwd) || die "Authentication failed\n";
The output on the Fedora instance is:
Net::SMTP>>> Net::SMTP(3.11)
Net::SMTP>>> Net::Cmd(3.11)
Net::SMTP>>> Exporter(5.74)
Net::SMTP>>> IO::Socket::IP(0.39)
Net::SMTP>>> IO::Socket(1.40)
Net::SMTP>>> IO::Handle(1.40)
Net::SMTP=GLOB(0x564c8ac970b0)<<< 220 SG ESMTP service ready at ismtpd0027p1las1.sendgrid.net
Net::SMTP=GLOB(0x564c8ac970b0)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250-smtp.sendgrid.net
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250-8BITMIME
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250-PIPELINING
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250-SIZE 31457280
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250-STARTTLS
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250-AUTH PLAIN LOGIN
Net::SMTP=GLOB(0x564c8ac970b0)<<< 250 AUTH=PLAIN LOGIN
Authentication failed
The code is exactly the same on both instances but with the Fedora instance Authentication consistently fails.
Manually connecting to sendgrid via the command line also works.
Thank you in advance!
I have a script which does ssh to number of servers (#alive_hosts) stored in an array and executes certain commands on those hosts (these hosts are IP address).
...
use Net::Ping;
use Net::OpenSSH;
use Parallel::ForkManager;
#these hosts are the IP addresses
my #hosts = ("host1", "host2", "host3", "host4", "host5");
my $p = Net::Ping->new();
foreach my $hostname (#hosts){
my ($ret, $duration, $ip) = $p->ping($hostname);
push (#alive_hosts, $hostname) if $ret;
}
my $ssh;
my $command = "perl -e "print \"Hello..\"";
my $pm = Parallel::ForkManager->new(5);
LOOP:
foreach my $n (#alive_hosts) {
my $pid = $pm->start and next LOOP;
#doing ssh to the host and running the command
#lets say here I am executing simple Perl command
$ssh = Connect($n, "user", "passwd");
$ssh->capture($command);
$pm->finish;
}
$pm->wait_all_children;
undef $ssh;
sub Connect {
my ( $host, $user, $passwd ) = #_;
my $ssh = Net::OpenSSH->new($host, user=>$user, password=>$passwd);
$ssh->error and die "Couldn't establish SSH connection: " . $ssh->error;
return $ssh;
}
...
When I execute this script, I am getting below error after certain time.
Warning: Permanently added 'host5' (RSA) to the list of known hosts.
Couldn't establish SSH connection: unable to establish master SSH connection: master process exited unexpectedly at script.pl ....
Actually $command is able to run in host1 to host4. But when it takes host5, its unable to run it.
I could able to ping host5 and connecting looks fine to me. But through the script it always fails to execute the command.
I have tried putting master_opts => [-o => "StrictHostKeyChecking=no", '-vvv'] in $ssh object in Connect() subroutine.
In capture, I added timeout period like this - $ssh->capture({timeout = 10}, $command);
But didn't succeeded in both the cases.
ssh version: OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
Any idea why it's failing to run command in last host always?
I have a code that list files through an ftp directory but I want to be able to only list files that are older than 20 minutes.
use Net::FTP;
#Global variables that i am not going to list down..
my $pattern = 'fi*';
my #remote_files;
my $ftp = Net::FTP->new($host) or die "Error connecting to $host: $#";
$ftp->login($username,$password) or die "Login failed: ", $ftp->message;
$ftp->cwd($ftpdir) or die "Can't go to $ftpdir: ", $ftp->message;
print $ftp->pwd();
#remote_files = $ftp->ls($pattern);
foreach my $file (#remote_files){
print "file: $file\n";
}
$ftp->quit or die "Error closing ftp connection: ", $ftp->message;
nvm i solved this on my own i used
$ftp->mdtm($file);
to get the time for the file and compare it with the current time minus than 20 minutes.
so i'm using vmean on a series of HMS values. because I don't care about fractions of seconds i convert the hms value to seconds, floor that value and then cast back to HMS. Which works fine, however, I have been unable to figure out how to remove the trailing dot from the seconds field.
what I have:
#II .. #III = (0# 15' 36", 0# 16' 7", 0# 16' 36", 0# 17' 05")
0# 16' 21." = #7$4 = hms(0,0,floor(deg(vmean(#II..#III))*3600))
what I want:
0# 16' 21" = #7$4
Define a calc function that converts the seconds of an hms value to an integer:
(defmath hmsIntSecs (v)
(let ((x v))
(setq x (nreverse x))
(setcar x (calcFunc-round (car x)))
(setq x (nreverse x))
)
)
Be sure to evaluate the function definition before proceeding.
What I get with just vmean:
| 0# 16' 21." | 0# 15' 36" | 0# 16' 7" | 0# 16' 36" | 0# 17' 05" |
#+TBLFM: $1=vmean($2..$5)
Now what I get using hmsIntSecs:
| 0# 16' 21" | 0# 15' 36" | 0# 16' 7" | 0# 16' 36" | 0# 17' 05" |
#+TBLFM: $1=hmsIntSecs(vmean($2..$5))
open (HAN1, "<test1.txt") || die "not existing!";
open (HAN2, "test2.txt") || die "not existing!";
s/nameserver/nameserver/g;
print HAN2 $_;
}
close(HAN1);
close(HAN2);
~
test1.txt
nameserver 10.66.80.10
nameserver 10.66.80.11
nameserver 10.66.80.11
test2.txt
search test.com
nameserver 99.66.80.10
nameserver 98.66.80.11
nameserver 98.66.80.11
After running the script test2.txt its removing other string content.
nameserver 10.66.80.10
nameserver 10.66.80.11
nameserver 10.66.80.11
But want the result test2.txt
search test.com
nameserver 10.66.80.10
nameserver 10.66.80.11
nameserver 10.66.80.11
Try this ,
use strict;
use warnings;
use Data::Dumper;
open (HAN1, "<test1.txt") || die "not existing!";
open (HAN2, "<test2.txt") || die "not existing!";
my $current;
my #arr1 = <HAN1>;
foreach $current (<HAN2>) {
unless ($current =~ /nameserver/) {
print $current;
next;
}
foreach (#arr1) {
my($first,$second) = split (' ',$_);
$current =~ s/^(nameserver\s+).+/$_/g;
chomp($current);
print $current;
last;
}
shift #arr1;
}
close(HAN1);
close(HAN2);