Programming :: Converting Bash Script Into PHP?
Jul 5, 2011
I wrote the following as our developers won't do it for us! The rest of my programming is in PHP, any ideas on how I can get this into php?I'm in the middle of writing a reminder system which involves importing the customer data and sending out reminder emails.All the script below does is download the current report $FILEIN, compare field number 6 ($DATA) with the date($DATE), if there is a match, it checks each line in the prescription_skus.csv to see if there is a match with field number 1 in the current report. It then outputs the entire line to $FILEOUT
Code:
TODAY=`date +"%Y-%m-%d"`
FILEIN="export-"$TODAY".csv"
[code]...
View 7 Replies
ADVERTISEMENT
Aug 2, 2010
I need to convert strings in the format YYYYMMDD to dates so I can perform date arithmetic.
View 4 Replies
View Related
Jan 30, 2010
I am taking an input from the user for free and Used capacity in a disk. I wish to convert Input entered in MBTB to GB and this is how i am doing it.
Code:
<some code>
print "Enter Total disk space";
$tot = <STDIN>;
convert($tot);
[code]...
how do i pass the value of conv[0] after conversion back to $tot or $use such that they contain only value which is in GB?
View 3 Replies
View Related
Jan 22, 2011
I'm working on a project where I am converting a C file to C++. I have worked out 99% of the errors but there is still one lingering one that I cant seem to figure out. I get the following error when compiling with g++
Code:
mscp.cpp:749: error: invalid conversion from const void* to move
mscp.cpp:750: error: invalid conversion from const void* to move
[code]...
View 5 Replies
View Related
Apr 3, 2011
My problem is to convert an odt file to pdf using php. I wrote an article in odt and I'd want to download it in pdf from my site. I know "fpdf", but it doesn't convert from odt. Someone says to convert from odt to html then to pdf... but some others says NO! Well, do you know a way? (may be also different from odt to pdf, e.g. from latex to pdf).
View 12 Replies
View Related
May 17, 2011
I've been converting some C code to assembly for my homework; it was going well but I'm having trouble with a for loop for hours. I could not understand where is the problem and decided to ask. I'm posting the part where I'm having trouble of my C-code and assembly-code; every other part of codes act same and the variable values are same. I'm waiting this two codes to act same, but they don't.
Code:
mov ebx, [result]
mov eax, [i]
mov ecx, [ebx+eax]
mov [j], ecx
mov [ebx+eax], byte '.'
_loop:
mov ebx, [result]
mov eax, [i]
inc eax
mov cl, [ebx+eax]
cmp cl, 'Z'
je _continue
mov ebx,[result]
mov eax,[i]
inc eax
mov ecx, [ebx+eax]
mov [k], ecx
mov ebx, [result]
mov eax, [i]
inc eax
mov ecx, [j]
mov [ebx+eax], ecx
mov ecx, [k]
mov [j], ecx
inc dword [i]
jmp _loop
_continue:
Code:
j=result[i];
result[i]='.';
for(;result[i+1]!='Z';i++){
k=result[i+1];
result[i+1]=j;
j=k;
}
View 10 Replies
View Related
Jul 16, 2011
I'm writing the Diffie-Hellman key exchange system using GMP to handle big integers. For the most part, everything works. I can convert the string to mpz_t, set up the keys and everything, and encrypt it fine. Its the decrypting I'm having issues with. What I'm using is mpz_xor() for both. To encrypt I'm doing mpz_xor(buffer, mpz_of_text, secret_key), and to decrypt I'm doing mpz_xor(buffer, mpz_of_cipher, secret_key).
For one character, it semi-works...it'll decrypt it fine, but it'll return it as it's ASCII value (i.e.: if I encrypt "A", it'll decrypt it as 65). Which, I can easily just do sprintf(decrypted_buffer, "%c", 65) for example and be fine. But, when I'm sending text bigger than one character, the encryption for AB gives me something like 1061043 after running the decrypting xor on it.
Has anyone ever done this before or can point me in some directions? Perhaps other algorithms to try? I know XOR isn't the most secure encryption method to use, but at the time I wasn't sure what else to use. I'm really just having a hard time trying to convert a mpz_t to a character string. I've looked at mpz_get_str() and it works before running encryption (i.e.: using mpz_set_str() to create a mpz of a string, then calling mpz_get_str() to change it back). Maybe my XOR method is wrong? Here's the code I'm using:
Code:
/**
* str2mpz()
* b The current buffer of text to convert [in]
* m The mpz_t variable to store converted text [out]
[code]....
View 9 Replies
View Related
Mar 25, 2010
I'm a C / assembler programmer so am not use to C++, which I need to use. Basically I'm using my own versions of memcpy, but for long and int rather than char. It's for fast graphics. So I have a char array which I copy to another array. But I copy as either longs or ints, much faster. for example
Code:
void * fastmemcpysprite (void *destaddr, void const *srcaddr, size_t len)
{
[code]...
View 3 Replies
View Related
Jul 21, 2011
#!/usr/bin/perl
print "Input File Name: ";
$filename = <>;
$filename =~ s/s+$//;mkdir "$filename";
[code]....
View 3 Replies
View Related
Mar 4, 2011
I have a vector of octets that needs to be converted to a std string. I'm currently doing it this way:
Code:
stringstream ss;
for (unsigned int i=0; i < data.size(); i++
{
ss << data[i];
}
string s_data = ss.str();
This works, but is there any better way to do it?
View 2 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Jan 24, 2010
simple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
View 10 Replies
View Related
Apr 27, 2011
I have to write a code that converts a sequence of 1's and 0's(block) into their equivalent hexa number and copying to another array(byte). but this sequence is not always of length 8 and you are required to send strlen(sequence)%8 bits back into the string. So i've written down this code and it works well with the sample input but fails in the real program.
Code:
int Convert_encode( char * block,unsigned char * byte)
{
int len,iter,i,j,k,sum;
char * temp=(char *)malloc(4*sizeof(char));
len=strlen(block)/8;
[code]....
View 7 Replies
View Related
Nov 26, 2008
I have a config file that contains:
my.config:
Code:
Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.
Here is my parse_cmd script:
Code:
View 3 Replies
View Related
Jul 25, 2011
I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.
Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?
View 5 Replies
View Related
Apr 9, 2010
I am in the process of learning some scripting, however I am running into a roadblock in specifying a certain time format in the array. Ideally I would like to use Here are the lines of text that I am interrogating:
1123,3/25/2010,00:14 Thu,33229
1124,3/26/2010,13:30 Fri,33230
1125,3/27/2010,04:49 Sat,33231
[code]...
View 2 Replies
View Related
May 5, 2011
I have log files that everyday are downloaded from my webserver in the format: Code: samplesite.com.xxxxxxxxxxx.gz xxxxxxxxxx is a 10 digit epoch time. I am trying to figure out a way in batch to:
1. find all of exisiting files containing the pattern (after the first run it will only be one a day)
2. Isolate the epoch string
3. convert the epoch string to human readable date/time
4. rename the original file as samplesite.com.mmddYYYY.gz
View 2 Replies
View Related
Jan 9, 2010
I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:
Let FILE="thefilenameofsomefilesfor_instance.txt"
Code:
NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`
I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.
View 5 Replies
View Related
Mar 31, 2011
I need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
View 10 Replies
View Related
Jan 29, 2010
I have managed to create a HTML file inside python code,convert this to a PNG file through a Python script ?
EDIT: Details added: I have a python script which generates map-legends in the form of an html file. The legend generated have to be pasted on a map which is in a png format. A png format file can be pasted on another png format file easily. But because the legends generated are in a html format I cannot paste it on the map file !!
EDIT: Details added: I did Googling first but it resulted in various soft wares for above purpose which I don't want !!
View 12 Replies
View Related
Jul 21, 2011
I am new to scripting world and i have been assigned the task of converting some bat scripts to sh scripts because we migrate from Windows to Linux server.find below the .bat script.
rem *************************************************************************************
rem This script is used to get r2devices files.
rem
[code]...
View 3 Replies
View Related
Jan 29, 2011
I am trying to write a bash script that sources another bash script. Essentially, I need a few lines to check to see if a certain variable is set. If not, I set it manually, and then source a scripts with that variable in the path. I wrote a test script to try it, but for some reason the last line does not work. Here is what I wrote:
#!/bin/sh
source ~setupdir/setup.shrc #just a test, this line works
echo ${#SETUP} # prints 0 if setup is not set, which it isn't
if [ ${#SETUP} -eq 0 ]
then
SETUP="~setupdir"
fi
echo $SETUP # prints ~setupdir
[Code]...
View 5 Replies
View Related
Aug 9, 2009
I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.
echo '<input type="hidden" name="delete[]" value="'.$_POST['delete'].'" />';
View 4 Replies
View Related
Jul 13, 2011
i'm in the process of learing C++. currently i'm creating shell scripts to get things done. i'm just curious how, as a programmer using C++ you would get a similar job done.as an example i have a script that takes the contents of files, pipes it to some sed and awk commands, which is piped to create a new file. that file is then imported into a mysql database.if you were going to do this in C++, would you call the sed/awk programs to modify the file, or can it be done within the program itself? i'm probably jumping the gun here because i've just started learing about pointers so this is above my ability
View 12 Replies
View Related
Mar 25, 2011
I have beat this enough and don't get what should have been a very simple thing to do. I build a variable;
Code:
CLIST=java,lua,python,php,perl,ruby,tcl
CLIST will be used by another bash script but I need to replace the commas with a space. I
[code]...
View 2 Replies
View Related
Dec 4, 2010
Creating script that converts hex to dec. But without using bc calculator or other methods that could convert it in one line. I need to make something like this script that converts dec to hex.
View 1 Replies
View Related
Apr 14, 2011
I have a basic awk script that can read a file named 'server_info' and output to the screen which fax lines are not working. Now I want to make the script execute commands instead of printing to the screen but I am having trouble... This is better explained by my code below:
test.sh Code: #!/usr/bin/awk -f
#
#The name of this script is test.sh
[code]....
View 1 Replies
View Related
Jul 14, 2011
Distro: Centos 5, PHP 5I have done a bit research on running bash commands from php and there was little success. This is my relevant php script
<?php
echo exec('pwd');
?>
[code]...
View 16 Replies
View Related
May 2, 2011
I am trying to build a function inside a script.
Code:
#!/bin/sh
#System commands and other configurable.
IPT=/sbin/iptables
IP6T=/sbin/ip6tables
IPST=/usr/sbin/ipset
MODP=/sbin/modprobe
GET=/usr/bin/wget
INT_NET=192.168.1.0/24 .....
I can find lots of tutorials in how to use if, then, else. However, how do I define a variable inside the function?
SEE>>
Code:
for c in $ISO
Also, am I using the 'test' command correctly( -/+ week as valid test)?
View 7 Replies
View Related
Feb 14, 2011
I'm somewhere between Novice and I have no idea what I'm doing with bash scripts. I'm writing a script to deploy images using partimage on my company's desktops, and while I have just about everything else figured out I have one issue left.Each of our 4 sites that will be using this disc will have a deployment server due to the fact that our sites have dedicated point to point links that our business traffic is conducted on. I need to be able to determine what site I'm at based onubnet and set a variable based on this determination. What I don't know is how to get the IP address in to an if statement, and properly determine subnet. For example:
192.168.1.0/16 - 192.168.7.0/16 need to use DEPLSERV01
192.168.8.0/16 - 192.168.16.0/16 use DEPLSERV02
192.168.17.0/16 - 192.168.24.0/16 use DEPLSERV03
View 1 Replies
View Related