Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
passing variables to php command line
Old 06-06-2005, 06:33 AM passing variables to php command line
bez
bez's Avatar
Skilled Talker

Posts: 53
Trades: 0
I need to run an encryption function from php in the command line. i have the file encrypt.php:

$table = file('tblCandidate.txt');
$table = implode($table);
$table = blowfish_encrypt($table, 'encryption_password');

//now we have string stick in file
if (file_exists("to_send")) unlink("to_send");
$to_send = fopen("to_send", 'w');
fputs($to_send,$table);
fclose($to_send);
exit(0);

blowfish function is in the file also, not included for the sake of brevity.

i run the file (in windows) with:

C:\PHP\php -f c:\development\encrypt.php

What I want is to make the filenames (tblCandidate.txt & to_send) variables that are passed to the script from the command line, like:

C:\PHP\php -f c:\development\encrypt.php tblCandidate.txt to_send

Im pretty sure its possible, but not sure the format (from the command line or in the script).

Also, do we make filenames passed this way relative to script, or relative to where you call the script from?

Can anybody help me out? Cheers
bez is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-06-2005, 08:43 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
If you start the sript in a way you described than filenames will be:
PHP Code:
$tblCandidateFname $argv[1];
$toSendFname $argv[2]; 
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 06-06-2005, 09:39 AM
bez
bez's Avatar
Skilled Talker

Posts: 53
Trades: 0
that does exactly what i want, cheers
bez is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to passing variables to php command line
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11676 seconds with 12 queries