Unsure of how to proceed with creating ec2-consisten-snapshot - perl

I was just put on a task to try and debug and figure out why our ec2-consistent-snapshot script isn't working.
Our lead programmer followed this blog post.
We have a .sh script that we'd like to take the snapshot and it looks like this:
#!/bin/sh
/opt/aws/bin/ec2-consistent-snapshot --aws-access-key-id MYACCESSKEY --aws-secret-access-key MYSECRETKEY --freeze-filesystem /vol --mysql --mysql-host localhost --mysql-socket /var/lib/mysql/mysql.sock --mysql-username USERNAME --mysql-password PASSWORD --description "Demo MySQL data volume: $(date +%c)" vol-MYVOL
If I run this by doing sudo ./snapshot_script.sh I get a single error:
ec2-consistent-snapshot: ERROR: create_snapshot: File does not exist: at /usr/share/perl5/vendor_perl/Net/Amazon/EC2.pm line 232
I of course followed this error and line 232 in EC2.pm is this:
my $ref = $xs->XMLin($xml);
I have 0 perl experience and I don't know what this could be doing.
Any help would be wonderful.

The Net::Amazon::EC2 that I'm looking at on CPAN has that line at 252, not 232 so perhaps you are not on the latest version. Looking above that line, the program has attempted to do a "query to sign" using lots of the security parms. I suspect there is a problem with the authentication keys you are using. There is a debug flag, you might want to turn that on to generate more messages.

If you go to this page, you will see that XMLin() is a function of XML::Simple, and it takes a file as an argument. So, $xml is presumably a variable that contains an xml file name. That file does not exist.
The next step would be to trace the error back into the source code of ec2-consistent-snapshot, in order to see how it is calling XML::Simple and where the bad value gets passed in.

Related

Perl Script for Bulk Adding Users to a Group after it Reads from a CSV Line

I'm attempting to bulk add users to a group using a CSV file and I'm running into a few frustrating errors that I can't seem to find online elsewhere:
useradd: invalid shell '-d/home/jbower11' --(for all users in the list)
Use of uninitialized value $fields[0] in concatenation (.) or string at csvreader.pl line 14, line 6. --(for all users in the list)
useradd: invalid shell '-d/home/' --(An additional error that pops up after the script has run.)
system("useradd -gstudents -c $fields[0],$fields[1] -s -d/home/$fields[2] -m $fields[2]");
The -s option specifies the new user's default shell. You are passing -d/home/$fields[2] which is not a valid shell name
There is also a blank line at the end of your data file which you are not discarding
Please use the passive facilities available on the internet to diagnose your problems before resorting to personal assistance, and make an attempt to format your questions properly if you really do need help

postgreSQL COPY command error

Hallo everyone once again,
I did various searches but couldn't gind a suitable/applicable answer to the simple problem below:
On pgAdminIII (Windows 7 64-bit) I am running the following command using SQL editor:
COPY public.Raw20120113 FROM 'D:\my\path\to\Raw CSV Data\13_01_2012.csv';
I tried many different variations for the path name and verified the path, but I keep getting:
ERROR: could not open file "D:\my\path\to\Raw CSV Data\13_01_2012.csv" for reading: No such file or directory
Any suggestions why this happens?
Thank you all in advance
Petros
UPDATE!!
After some tests I came to the following conclusion: The reason I am getting this error is that the path includes some Greek characters. So, while Windows uses codepage 1253, the console is using 727 and this whole thing is causing the confusion. So, some questions arise, you may answer them if you like or prompt me to other questions?
1) How can I permanently change the codepageof the console?
2) How can I define the codepage is SQL editor?
Thank you again, and sorry if the place to post the question was inappropriate!
Try DIR "D:\my\path\to\Raw CSV Data\13_01_2012.csv" from command line and see if it works - just to ensure that you got the directory, file name, extension etc correct.
The problem is that COPY command runs on server so it takes the path to the file from the server's scope.
To use local file to import you need to use \COPY command. This takes local path to the file into account and loads it correctly.

export PATH creating a redundant path

I need to add some perl scripts to PATH, but when I do, and try to run the scripts, it can't find the files. For some reason it is using a redundant path and doesn't find it. I dont know how to describe the problem but the code is pretty self-explanatory.
[lsk250#murphy portfolio-handout]$ pwd
/home/lsk250/portfolio-handout
[lsk250#murphy portfolio-handout]$ export PATH=$PATH:/home/lsk250/portfolio-handout/
[lsk250#murphy portfolio-handout]$ time_series_symbol_project.pl
env: /home/lsk250/portfolio-handout//home/lsk250/portfolio-handout/get_data.pl: No such file or directory
sh: line 1: 17758 Aborted (core dumped) time_series_project _data.in 8 AWAIT 300 ARIMA 2 1 2 2> /dev/null
Any ideas whats the right export command I should use to get this right?
There is nothing wrong in how you export PATH variable except that you may already have your "pwd" there.
As far as I can see the get_data.pl is called from time_series_symbol_project.pl (or from some other script called from time_series_symbol_project.pl and so on) and I would check how it is called.
Perhaps you could also see if PATH is changed somewhere in your scripts.
i'm guessing the "shebang" line (#!) and/or file permissions on 'get_data.pl' is incorrect.

How to find a workaround for latexdiff /latexdiff-vc on Windows on filenames containing spaces

I'm running latexdiff v 0.25 and when I attempt latexdiff-vc --svn -r "myFile with spaces.tex" I get the following command line output:
Working on myFile with spaces.tex svn: 'myFile' is not under version
control Running latexdiff 2 and only 2 non-option arguments required.
Write latexdiff -h to get help Something went wrong in latexdiff.
Deleting myFile with spaces.tex and abort
I'm assuming it's a bug where the right filename isn't passed correctly to svn. The command runs fine on names w/o spaces.
Does anyone know a workaround?
Assuming you are doing this manually, you may be able to use the 8.3 file name that you can get on the command line using dir /x.

Perl script not sending mail and not unlink - ing

I have some scripts that I didn't write... they search a Squid log database and then create a spreadsheet and email it and then delete the .pid and .xls files it created.
The scripts were using NTLM for one of it's variables (request_user)... I changed it to a manually entered text field.
I don't know perl and the scripts are not working.
The .pid and .xls are getting created but nothing gets emailed and the files don't get deleted (unlink)
Here is are the links to the request and generate files
http://www.the-greenes.net/spreadsheet_request-test.txt
http://www.the-greenes.net/spreadsheet_gen.txt
Can anyone help a limited guy with very limited perl skills?
Thanks
In the spreadsheet_gen script you have this line to setup address to smtp server:
my $mail_server=`10.0.1.98`;
Using backticks make it run command named 10.0.1.98 and assign its output into $mail_server variable. This is most likely wrong, try to replace backticks with regular apostrophes to create string:
my $mail_server = '10.0.1.98';
Can you see any error in your error.log? If $message->send ... fails, it dies with error message and nothing gets sent nor unlinked.