How do you remove a metacharacter from a file name. I have a filename of cos.NEW&OLD.0826.12345 but the perl script only recognizes cos.NEW. The NEW&OLD is a EDI Trading Partner ID. I want to remove the ampersand and replace it with an underline so that the code does not generate a false alert. I tried $script=~s/(\W)/_/g; but is that to replace what is in the contents of the file because I am still getting the error message.
08/26/2009_16:16:36 14802 ***ERROR: cannot upload data file /usr/edi/cos.NEW&OLD.0826.14802 into Database 08/26/2009_16:16:36 14802 *** ALERT 521
Snippet of code below
$script=$ARGV[3]; # Value of this $ARGV is NEW&OLD : : $otis_db="$base_dir/otis_db/cos.$script.$cdate.$pid"; : : : : chomp($end_date=`date +%m/%d/%Y_%T`); $end_date=~s/_/ /g; $values="(\'$file_name\',\'$send_from_dir\',\'$serv_ref\',TO_D +ATE\(\'$end_date\',\'MM\/DD\/YYYY HH24:MI:SS\'))\;"; : I placed this line right before the echo statement. Was getting an er +ror could not upload " cos.NEW&OLD.082609.12345" because it could not + be found. But it did create the file "cos.NEW". The & and anything + after is ignored. $script=~s/(\W)/_/g; : `echo "INSERT into COSBRIDGE\n\tvalues$values\n" >> $otis_db`;
In reply to Removing a Metacharacter from a filename by sputnik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |