Typo3 - record history weird behaviour - typo3

I am facing a weird problem which I've never seen before in typo3 version 6.0,
but right now I have to use typo3 4.5.29.
There's something wrong with the "record history", when I try to display change history of a page content, this is what I see:
Normally in the "Differences" column I would see the changes in green colored text and
the old values which were removed in red colored text, but I see some kind of number
which I don't even understand the meaning...
Anyone is facing the same thing ?
Thank you very much for your help.
Cindy

TYPO3 uses external software called "diff" for creating a coloured view of the difference. Have a look at t3lib/class.t3lib_diff.php for implementation details.
I guess $GLOBALS['TYPO3_CONF_VARS']['BE']['diff_path'] is set wrong or diff is not available.
untested:
If you cannot ask the admin of your server, create an php-file somehow like this for testing purpose:
<?php
$GLOBALS['TYPO3_CONF_VARS']['BE']['diff_path'] = '/usr/bin/'; // do not know your system
$file1 = '';
$file2 = '';
$cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['diff_path'] . ' ' . $file1 . ' ' . $file2;
$res = array();
echo exec($cmd, $res, $returnValue)
echo $res;
?>
This file should output something like
diff: missing operand

Related

perl variables from open file doesn't work

i need some help with a sendmail perl script.
So i have 1 part of html message included from file msg.txt and second part is already in my $html
I have 2 variables into msg.txt(first part) that doesn't work.. in the second part it works fine..
EDIT : So . in the msg.txt file i have the following : $website,$token that is declared in perl script. When i run the script i receive email containing names of variables($token,$website) instead value of variables..
CODE
$website = "domain.com";
$token = 'token123456';
open(IN,$list);
while(chop($email_line=<IN>)) {
local $/ = undef;
open MSG, "msg.txt";
$msg = <MSG>;
close FILE;
my #html = "
<html>
$msg (!!! variables $website and $token doesn't work in $msg !!!)
<div style='margin-top:5px; text-align: center;>
Website : $site | Token : $token ( variables are working)
</div>
</html>
";
}
OUTPUT
// this is first part
Website : $website | Token : $token
//this is second part that works
Website : domain.com | Token : token12345
You interpolate the contents of $msg into #html (which should probably be a scalar variable, not an array) and then you expect the Perl compiler to automatically run another level of interpolation to expand the variables that were in $msg and are now in $html. And Perl simply doesn't work like that. It only does a single level of interpolation without you jumping through a few hoops in order to tell it what you want it to do.
If you want to be a successful Perl programmer, then I highly recommend taking a few hours to read through the Perl FAQ. It will make your Perl programming life easier and more productive.
In particular, it includes this question and answer:
How can I expand variables in text strings?
The answer shows a complex method using a double /ee flag on a substitution operator, but it also gives the correct answer which is "use a templating system".

Vcf to Bayescan format - perl script not recognising populations

I am trying to convert a .vcf file into the correct format for BayeScan. I have tried using PGDSpider as recommended but my .vcf file is too big so I get a memory issue.
I then found a perl script on Github that may be able to convert my file even though it is really big. The script can be found here. However it does not correctly identify the number of populations I have. It only finds 1 popualtion, whereas I have 30.
The top of my population file looks like so, following the example format in the perl script.
index01_barcode_10_PA-1-WW-10 pop1
index02_barcode_29_PA-5-Ferm-19 pop2
index01_barcode_17_PA-1-WW-17 pop1
index02_barcode_20_PA-5-Ferm-10 pop2
index03_barcode_16_PA-7-CA-14 pop3
I have also tried the script with a sorted population file.
I have no experience with perl language so I am struggling to work out why the script is not working.
I think it is to do with this section of the script but cannot be sure:
# read and process pop file
while (<POP>){
chomp $_;
#line = split /\t/, $_;
$pops{$line[0]} = $line[1];
}
close POP;
# Get populations and sort them
my #upops = sort { $a cmp $b } uniq ( values %pops );
print "found ", scalar #upops, " populations\n";
Appolgies as I am not sure how to make this a reproducible example but I am hoping someone could at least help me understand what this part of the code is doing and if there is a way to adapt it? Isthe problem that my individual names include _ and -?
Thank you so much for your advice and help in advance :)
Firslty thank you to #toolic for his help and guidance :)
Whilst trying to create a reproducible example it started working and I think the problem is how I made my populations file.
Previously I used: paste sample_names pops | column -s $'\t' -t > pop_file.txt
to output the file printed in the question.
However it works if i simply use: paste sample_names pops > pop_file.txt
Also I have put the full path to the .vcf file instead of path from the current directory.
I hope this helps anyone who comes across this issue in the future :)

How to download a string as a .csv file, without writing the string to a file and reading from the file?

I am re-designing a website where, based on the options selected by the user, I need to fetch data from a DB and then give it in a downloadable format to the user. I am fetching the data into a string variable, but I dont want to write it to a file and then write the download code. I want to download the string to a file on the client side. I am using perl for this.
Previously I was reading and downloading from a file using this perl-cgi code :
...
my $ID = "details.csv";
my #fileholder;
my $filesloc = "/html/details.csv";
open(DLFILE,'<',"$files_loc") || Error('open','file');
#fileholder = <DLFILE>;
close(DLFILE)
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print #fileholder;
Which is saved as downloadscript.cgi. But now, I want to do this in a .pm file, and I am storing string values in #fileholder. I tried with :
my $ID = "details.txt";
my #fileholder = qw(name age address);
print "Content-Type:text/plain\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print #fileholder;
in the .pm file, but it is PRINTING the above lines on the screen instead of opening the 'save as' dialog. Both are perl, so where am I going wrong?
EDIT : I got to know the reason, Its because I am previously opening a html content type, and then in the middle, I am opening this "Content-Type:text/plain\n" - this is where the browser gets confused. Now, could someone please tell me how to close the previous html content-type and open this new content type for downloading?
This is because the browser is viewing the content-type you create and send with print "Content-Type:text/plain\n"; - as #Julian mentions you could try changing that line back or adding the line print "Content-Type:application/x-download\n"; after the text/plain line and see if this fixes things. Since that particular content-type may actually need a real file to to work with, you could try other content-types (see #Hunter McMillen's suggestion) since the browser may offer a download/save dialog in that case.
You might need to add the following to fool the browser (and remove the text/csv):
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
Okay, looks like there can be only one content-type set for one response. So, I am now navigating to another page from my current page, where I am writing the download code. Thanks for your help people!

Concatenating strings to a path

I'm having some trouble with concatenation on strings. I'm tring to create a path that will become a .txt file, but it always ends up as just ".txt" with no name. It ends up in the right fikder though.
This is what I'm doing:
open TEXT, ">/home/admin/www/build/logs/baseline".$ID."/".$platformName.".txt" or die $!;
So I want to create the file.
"/home/admin/www/build/logs/baseline45/linux.txt"
Where am I messing this up?
Thanks!
You are not messing up in the snippet provided, there are several ways of forming a string including values from variables and you are using one of them (the dot-operator) correctly.
Try checking so that $platformType really contains what you think it, and unless you haven't already; turn warnings (and preferrably strict mode) on.
Turning warnings/strict mode on might give you details of undefined variables which would be helpful in situations such as this (ie. Is $platformType really the name of the variable you are looking for?)
use warnings;
use strict;
Print the value of $platformType before trying to open the file and you will find that it is indeed an empty string (or just containing something weird that would explain the results you are getting).
Step 1:
open TEXT, '>/home/admin/www/build/logs/baseline/' . $ID . '/' . $platformName . '.txt';
Step 2:
open TEXT, ">/home/admin/www/build/logs/baseline/" . $ID . "/" . $platformName . ".txt";
I think like this..........

WWW::Mechanize and "HTTP::Message content must be bytes at..."

I'm writing simple program which has to change some data on Polish auction site.
One of the steps involves loading edit page, changing one value, and submitting it.
Sample page can be viewed here: http://depesz.com/various/new_item.php.html - this is just static copy of such edit page.
Relevant part of my perl code:
$agent->form_number( 1 );
$agent->submit();
$agent->form_number( 1 );
my $q = $agent->current_form()->find_input( 'scheme_id' );
$agent->field('scheme_id', '1025');
# $agent->field('description', encode('utf-8', $agent->value("description")));
# $agent->field('location', encode('utf-8', $agent->value("location")));
# $agent->field('transport_shipment_description', encode('utf-8', $agent->value("transport_shipment_description")));
$agent->submit;
print $agent->response->decoded_content . "\n";
After first submit I get the page I showed. Then I change value in scheme_id field to 1025, and submit the form.
Afterward I get:
HTTP::Message content must be bytes at /usr/local/share/perl/5.8.8/HTTP/Request/Common.pm line 91
I tried to recode values on text fields on the form - hence the agent->field(... encode) lines, but it didn't help.
At the moment I have no idea what on the form can make WWW::Mechanize fail in such way, but I clearly cannot fix in on my own.
Is there any way to debug this situation? Or perhaps I should do something differently?
Make sure your LWP and WWW-Mechanize modules are fully up to date. LWP fixed a number of encoding problems in late 2008, if I recall correctly.
I have the same problem.
Solved it with :
my $newcontent = encode('utf-8', $file);
before posting the content!
thanks,
mike
see http://www.perlmonks.org/?node_id=647935