#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Using shell_exec to create output file adds 2 questions marks to the end of filename


    (PHP Version 5.3.3-7+squeeze15)

    Hello,

    I am very very new to PHP, so I appreciate the patience and assistance.

    For the following block of code, for some reason two question marks ("??") are being appended to the end of the filename of the output file when it is created on disk.

    So instead of the filename being something like...

    valueOFarg1_valueOFarg2_valueOFarg3

    ...the filename is...

    valueOFarg1_valueOFarg2_valueOFarg3??

    (emphasis on the trailing questions marks)

    Thank you for your help!

    CODE BLOCK:

    <?php
    $arg1_TEST1 = $_REQUEST['arg1'];
    $arg2_TEST2 = $_REQUEST['arg2'];
    $arg3_TEST3 = $_REQUEST['arg3'];

    shell_exec('#!/bin/bash
    FILENAME='.$arg1_TEST1.'_'.$arg2_TEST2.'_'.$arg3_TEST3.'
    date > ./$FILENAME
    echo '.$arg1_TEST1.':'.$arg2_TEST2.':'.$arg3_TEST3.' >> ./$FILENAME
    date >> ./$FILENAME
    exit');
    ?>
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    $arg3_TEST3 almost certainly has some non-printable characters at the end of it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo