I have this command line which already runs into a cpanel hosting:
mysql -hlocalhost -e "use xxx_xx; update xxx_jshopping_manufacturers set manufacturer_publish = 0 where \`name_es-ES\` NOT IN ('BULL SOUND', 'ROYAL', 'BLACK + DECKER (ELECTROD)', 'SAMSUNG', 'DAEWOO', 'OSTER', 'WAHL', 'REMINGTON', 'BROTHER', 'CORELLE', 'SINGER', 'PANASONIC', 'FRIGIDAIRE', 'LG', 'PHILIPS ELECTRONICA', 'PIONEER', 'SONY', 'MOTOROLA', 'DEWALT', 'APPLE', 'JVC', 'MAXELL', 'WELL', 'STANLEY', 'LASKO', 'WESTINGHOUSE', 'CATA', 'FARBERWARE', 'BLACK & DECKER (HERRAM)', 'PHILIPS', 'BLAUPUNKT', 'RAYOVAC', 'BLU', 'JBL', 'BLACK & DECKER (HERRAM)','MUEBLES', 'ALTEC', 'SMART BALANCE', 'NEWLINK', 'YEZZ', 'HUAWEI', 'FORD', 'WINDMERE','DRIJA','REAL SALOON','INGCO'); select count(product_id)as '--- Product quantity ---' from xxx_jshopping_products; select \`name_es-ES\` as '--- Brands that are hidden ---' from xxx_jshopping_manufacturers where manufacturer_publish = 0;" | mailx -r sender#domain.com -s 'your site has been updated' destination#domain.com cc#domain.com
This command runs a query in mysql DB to hide some items and then email the results, it worked all time without issues until now that I have to move this site to a Centos / plesk hosting, I have made changes to the script to include user and password and it runs as always by clicking on the "Run now" button on the plesk scheduled task panel, however, when I click the "Ok" button to save the cron, it is given me this error
Error: Incorrect parameter values. cmd: The command cannot be longer than 980 characters.
Is there a way to get rid of that limit?
It is possible without addressing the maximum length issue.
Create a script file like this and it will run.
mysql -h hostname -otherParametersAsNeeded <<EOF1
use xxx_xx;
update xxx_database set ...
...
EOF1
Related
I have created a unix script to be executed after the session finished.
The script basically counts the lines of specific file and then creates a trailer with this specific structure:
T000014800000000000000000000000000000
T - for trailer
0000148 - number of lines
00000000000000000000000000000 - filler
I have tested the script in Mac, I know already that environments are totally different, but I want to know what is needed to be changed in order to execute this script successfully in IPC.
After execution I get the following error message:
The shell command failed with exit code 126.
I invoke the script as follows:
sh -c "$PMRootDir/scripts/exec_trailer_unix.sh $PMRootDir/TgtFiles"
#! /bin/sh
TgtFiles=$1
TgtFilesBody=$TgtFiles/body.txt
TgtFilesTrailer=$TgtFiles/trailer.txt
string1=$(sed -n '$=' $TgtFilesBody)
pad=$(printf '%0.1s' "0"{1..8})
padlength=8
string2='T'
string3=$(printf '%s%*.*s%s\n' "$string2" 0 $((padlength - ${#string1} - ${#string2} )) "$pad" "$string1")
string4='00000000000000000000000000000'
string5=$(printf '%s%*.*s%s\n' "$string3" 0 $((${#string3} - ${#string4} )) "$string4")
echo $string5 > $TgtFilesTrailer
Any idea would be great.
Thanks in advance.
Please check below points.
it looks like permission issue. Please login using informatica user(the user that runs infa demon) and run this command. You should be able to get the errors.
sh -c "$PMRootDir/scripts/exec_trailer_unix.sh $PMRootDir/TgtFiles"
Sometime the server variable $PMRootDir in UNIX doesnt get interpreted and can result null value. Please use echo $PMRootDir to check if its working after logging into UNIX using above user.
You can create trailer file using Infa easily.
Just add an aggregator transformation right before actual target( group by a dummy field to calculate count(*)). Then add an expression transformation to create those strings. And then trailer file target. Just 3 more transformations.
| --> AGG --> EXP --> Trailer Target file
Final Tr --|--> Final Target
I'm following the wiki https://help.ubuntu.com/community/Xen#Manually_Create_a_PV_Guest_VM
(section "
Set Up Initial Guest Configuration
")
I downloaded the netboot initrd.gz from https://mirror.arizona.edu/ubuntu//ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/xen/
but in the .cfg , what should I specify for the "disk = " line? ---- my host box is not using LVM, so I'll have to use "file-backed storage" for PV disk image. (https://wiki.xenproject.org/wiki/Storage_options , indeed this worked when I gave --dir= instead of --lvm= when running the xml-create command in https://wiki.xenproject.org/wiki/Xen_Project_Beginners_Guide )
here is my current config:
yy#yy-70A4000HUX:~/ub_xen$ cat ub_xen.cfg
name = "ubud1"
kernel = "/home/yy/ub_xen/vmlinuz"
ramdisk = "/home/yy/ub_xen/initrd.gz"
#bootloader = "/usr/lib/xen-4.4/bin/pygrub"
memory = 1024
vcpus = 1
# Custom option for Open vSwitch
vif = [ 'bridge=xenbr0' ]
disk = [ 'vdev=hda,target=/home/yy/ub_xen/images' ]
# You may also consider some other options
# [[http://xenbits.xen.org/docs/4.4-testing/man/xl.cfg.5.html]]
yy#yy-70A4000HUX:~/ub_xen$
I ran the command with sudo xl create -c ub_xen.cfg
this worked fine first, giving me the regular install process on console, pulling install files from remote archive, but when it comes to the step of disk paritioning, it's showing me a "SCSI" partitioning choice, with no volumes / partitions/disks to be chosen.
I guess this is because I'm not setting the right value for "disk = [ ]" option. what should I use here if I use file-backed storage for PV (just like VMware does)?
thanks a lot
Yang
found it, huge thanks to the author here: https://www.systutorials.com/create-and-manage-virtual-machines-on-xen/
I am working on a webtool to mirror a Wordpress installation into a development system.
The aim is to have a Live system for production and a development system for testing. The webtool then offers a one-click-sync between those systems.
Each of the systems is standalone, with its own webroot, database and url.
I am having a trouble with the database dump in which I have to search all the references to the source and replace them with the URL of the destination (e.g.: "www.example.com" -> "www-dev.example.com").
What I need to do is:
Find all occurences of the URL and replace it with the new one.
IF the match also matches the format of a serialized string it should set the Field-Seperator, and reload the match, so that the actual length can be set in the array.
In a first attempt I tried to solve this with a 'sed' command looking as follows: sed -i.orig 's/360\.example\.com/360-dev\.my\.example\.dev/g'.
This didn't work because there are serialized arrays contained in the dump, containing the url. The sed command is no good for updating the string-length-indicator of the serialized arrays.
My latest attempt is to use an awk as suggested here, because it's capable of arithmetic operations.
My awk script looks like this:
/360[.]example[.]com/ {
sub("360.example.com", "360-dev.my.example.dev");
if ($0 ~ /s:[[:digit:]]+:["](http[s]?:\/\/)?360[.]example[.]com["]/){
FS="\"";
$0=$0;
n=length($2)-1;
sub(/:[[:digit:]]+:/, ":" n ":");
}
} 1
There seem to be some errors in my script, which I can't find. It does not replace all of the occurrences of the url and completely skips the length-indicator-update.
How can I fix my script to achieve what I want to do?
EDIT: (Added Input/Output samples)
Databasedump consists of the whole wordpress-database with CREATE TABLE IF NOT EXISTS and INSERT statements for each table and record.
Normal (unserialized) occurence:
(36, 'home', 'http://360.example.com/blogname', 'yes'),
should result in:
(36, 'home', 'http://360-dev.my.example.dev/blogname', 'yes'),
Serialized occurence:
(404, 'wp-maintenance-mode', 'a:21:{s:6:"active";i:1;s:4:"time";i:0;s:4:"link";i:1;s:7:"support";i:0;s:10:"admin_link";i:1;s:7:"rewrite";s:0:"";s:6:"notice";i:1;s:4:"unit";i:1;s:5:"theme";i:0;s:8:"styleurl";s:69:"http://360.example.com/wp-content/themes/blogname/css/maintenance.css";s:5:"index";i:0;s:5:"title";s:0:"";s:6:"header";s:0:"";s:7:"heading";s:0:"";s:4:"text";s:12:"Example Text";s:7:"exclude";a:1:{i:0;s:0:"";}s:6:"bypass";i:0;s:4:"role";a:1:{i:0;s:13:"administrator";}s:13:"role_frontend";a:1:{i:0;s:13:"administrator";}s:5:"radio";i:0;s:4:"date";s:0:"";}', 'yes'),
Should result in:
(404, 'wp-maintenance-mode', 'a:21:{s:6:"active";i:1;s:4:"time";i:0;s:4:"link";i:1;s:7:"support";i:0;s:10:"admin_link";i:1;s:7:"rewrite";s:0:"";s:6:"notice";i:1;s:4:"unit";i:1;s:5:"theme";i:0;s:8:"styleurl";s:76:"http://360-dev.my.example.dev/wp-content/themes/blogname/css/maintenance.css";s:5:"index";i:0;s:5:"title";s:0:"";s:6:"header";s:0:"";s:7:"heading";s:0:"";s:4:"text";s:12:"Example Text";s:7:"exclude";a:1:{i:0;s:0:"";}s:6:"bypass";i:0;s:4:"role";a:1:{i:0;s:13:"administrator";}s:13:"role_frontend";a:1:{i:0;s:13:"administrator";}s:5:"radio";i:0;s:4:"date";s:0:"";}', 'yes'),
EDIT 2:
Now using wp-cli to do the task of search & replace.
I've got a multisite setup with blogs numbered (2,3,9).
Executing wp search-replace --url=360.example.com '360.example.com' '360-dev.my.example.dev' results in an error, telling me that the Single-Site tables (wp_redirection_items and wp_redirection_groups) cannot be found.
This is true, because they really do not exist, but rather for each blog (e.g: wp_2_redirection_items and so on). This error results in over 9000 missed occurences in s&r. It's possible to replace everything with wp search-replace --url=360.example.com '360.example.com' '360-dev.my.example.com' wp_*. But it still throws the error.
As suggested by #archimiro the task now is done by wp-cli.
But as I am also having a multisite setup, which lead to some errors I had to figure out the command for a full database search-replace task.
The final command:
wp search-replace --url=360.example.com '360.example.com' '360-dev.my.example.dev' wp_*.
Without explicitly telling wp-cli to search&replace in ALL (wp_*) tables it would stop by the time a "table not found" error is thrown.
Also not awk or wpcli but this is a php function I wrote that seems to work well.
function snr($search, $replace, $inputfile, $outputfile){
$sql = file_get_contents($inputfile);
$sql1 = str_replace($search,$replace,$sql);
file_put_contents($outputfile,$sql1);
$serstrings = preg_split("/(?<=[{;])s:/",$sql1);
foreach($serstrings as $i=>$serstring) {
if (!!strpos($serstring, $replace)){
$justString = str_replace("\\","",str_replace("\\\\","j",explode('\\";',explode(':\\"',$serstring)[1])[0]));
$correct = strlen($justString);
$serstrings[$i] = preg_replace('/^\d+/',$correct, $serstrings[$i]);
}
}
file_put_contents($outputfile,implode("s:",$serstrings));
}
I've used this in past with success:
sed 's|360\.example\.com|360-dev\.my\.example\.dev|g' com.sql > local.sql
Edit: sorry not awk, but neither is wp-cli.
I found this online and verified that the command:
echo "\033]0;Name\007"
Changes my term name to "Name". I'm just wondering why and how does this happen, so that I can tweak this and use it in my scripts accordingly.
Thanks for the help in advance.
Azeem
Found this (\033 is the sequence for ESC) :
ESC ] 0 ; txt ST Set icon name and window title to txt.
In the man page : http://man7.org/linux/man-pages/man4/console_codes.4.html
So, Linux console implements :
a large subset of the VT102 and ECMA-48/ISO 6429/ANSI X3.64 terminal controls
However this methods does not seems to be portable because it depends of the implementation of the terminal.
I'm recording call via Monitor() Command.
When this command is running i can see two different files (Filename-in.wav and Filename-out.wav) and when Monitor() command is finished it mix those two file and merge them to one (Filename.wav) file.
So the problem is that i want to keep both file after Monitor Cmd Execution but i didn't found a way to do it.
So after the final execution of the Monitor command i will have three file not only one
Ex:
Filename-in.wav
Filename-out.wav
Filename.wav (the mixed one with outbound and inbound voice
So is there any body who can give me an easy solution
You can use custom script for mixmonitor. In that script you can do whatever you want, including files like you described.
http://www.voip-info.org/wiki/view/MixMonitor
Note, that in Filename.wav you have both inbound and outbound in different channels. So you can easy got inbound only by mute left channel and outbound only by mute right channel.
My solution is to change the code of the res_monitore.c and recompile it again.
This is the portion of code that delete the raw file
00295 if (delfiles) {
00296 snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
00297 ast_copy_string(tmp, tmp2, sizeof(tmp));
00298 }
Just we have to add this { delfiles = 0; }in line 00294
00294 delfiles = 0;
00295 if (delfiles) {
00296 snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
00297 ast_copy_string(tmp, tmp2, sizeof(tmp));
00298 }
I changed delfiles = 0 to force the function to not remove the file.
After that this is the command that you have to type :
cd /usr/src/asterisk-1.8.23.0
make
cp ./res/res_monitor.so /res/res_monitor.so.backup
cp ./res/res_monitor.so /usr/lib/asterisk/modules
/etc/ini.d/asterisk restart
and u keep using the Monitor() command as before with the functionality that keep the raw file (Filename-in.wav and Filename-out.wav and of course Filename.wav)
What arheops did not understand in that conversation is that the "command" argument is executed after the "in" and "out" legs have been mixed by (Mix)Monitor.
There is no other way to save the "receive" and "transmit" feeds than to either change the source code as l3on1das suggested (not good practice though), or upgrade to Asterisk 11+, which now (not surprisingly) supports the options -t and -r for MixMonitor() to respectively save the transmitted and received legs in addition to the mixed output.
Good luck to anyone digging in asterisk for speech segmentation.