LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-20-2015, 06:01 PM   #1
cbtshare
Member
 
Registered: Jul 2009
Posts: 610

Rep: Reputation: 42
Script Issue


I have written the following script to read value(Name) in a XML file and then based on that change the password.It works but I get this error sometime on execution :


Here is a snippet of the file I am traversing is

Quote:
<Node Name="MUN" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="root" Domain="" Password="a/5pqLSsMnvRfylxdN6coiFTdc2+$
<Node Name="ubunugit" Type="Connection" Descr="" Icon="mRemoteNG" Panel="General" Username="root" Domain="" Password="bBxKPKXIhw1wKEV9aEUN1yynoRGOWT$
</Node>
</Connections> <---- this is line 217, dont know why it is failing on this
Quote:
Use of uninitialized value in concatenation (.) or string at replace.pl line 27, <XML> line 217


Quote:
#!/usr/bin/perl

use strict;
use warnings;

my ($found, $pass, $name, $line, @array, @sarray, @files, @names, @password);

open(XML, "/home/stain/Downloads/REMOTEopen.xml") || die ("Error: $!");

@array=<XML>;

foreach(@array)
{

@sarray=split(" ", $_);



@names = grep /\bName=/, @sarray;
@password = grep /\bPassword=/ , @sarray;



foreach( @names, @password)
{

print ("Enter the plain text password for $_, password is currently $password[0]\n");
$pass=<>;
chomp($pass);
print qq(You will now swap $password[0] for Password="$pass"\n);
print "continue? y/n\n";
my $ans=<>;
chomp($ans);
if ($ans =~/y/im)
{
s/$password[0]/Password="$pass"/i;
}

}
can I get some assistance here, or even a better way to approach this, I even looked at hashes.

Thank you
 
Old 11-20-2015, 08:26 PM   #2
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,430

Rep: Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349
I wonder whether your error is related to the Password strings not being enclosed in double quotes.
 
Old 11-21-2015, 06:01 AM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 610

Original Poster
Rep: Reputation: 42
Thanks, No, I tried that it doesnt work
 
Old 11-23-2015, 07:02 PM   #4
LanceTaylor
Member
 
Registered: Nov 2015
Location: Houston, Texas, US
Distribution: RHEL/CentOS, Debian/Linux Mint, SLES
Posts: 40

Rep: Reputation: 19
You have two places where you have opening double quotes, but no closing double quotes:
Quote:
Password="a/5pqLSsMnvRfylxdN6coiFTdc2+$ ... Password="bBxKPKXIhw1wKEV9aEUN1yynoRGOWT$
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] shell script issue how to pass the license exceptance as yes through script rohaanembedded Programming 5 07-03-2013 02:46 AM
Issue in running commands in expect script from shell script yadvinder Programming 0 05-31-2012 05:07 AM
Issue with Script?? linuxshadow Linux - Newbie 1 06-11-2008 02:28 AM
sh script issue. UltraSoul Solaris / OpenSolaris 4 03-29-2007 05:31 PM
Script Issue gauge73 Linux - General 8 07-14-2003 09:50 AM


All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration