problem using bash variables with command-line perl in bash script
From: Marcus Claesson (m.claesson_at_student.ucc.ie)
Date: 11/27/03
- Next message: Douglas Lentz: "Re: command line interface handling asynchronicity"
- Previous message: Drieux: "Re: Sockets and Daemonizing - was Re: Count the no of times a script is called"
- Next in thread: Drieux: "Re: problem using bash variables with command-line perl in bash script"
- Reply: Drieux: "Re: problem using bash variables with command-line perl in bash script"
- Reply: John W. Krahn: "Re: problem using bash variables with command-line perl in bash script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: beginners@perl.org Date: 27 Nov 2003 18:04:15 +0000
Hi!
I have a problem with variables when using command-line perl in a bash
script. The script should update a date (in 2003-10-10 form) if the
argument, which is a file name, exists on the same line in the file
updated_files.txt.
#!/bin/bash
FILENAME=$1
UPDATED=`date +%F`
echo
echo "perl -wne 'if (/$FILENAME/) { s/\d{4}-\d{2}-\d{2}/$UPDATED/;print;
} ' updated_files.txt" #Exactly as below, to see how the command looks
like
perl -wne 'if (/$FILENAME/) { s/\d{4}-\d{2}-\d{2}/$UPDATED/;print; } '
updated_files.txt
exit
[marcus@neo Scripts]$ my_bash_script file1
perl -wne 'if (/file1/) { s/\d{4}-\d{2}-\d{2}/2003-11-27/;print; } else
{ print; }' updated_files.txt
Name "main::UPDATED" used only once: possible typo at -e line 1.
Name "main::FILE" used only once: possible typo at -e line 1.
Use of uninitialized value in regexp compilation at -e line 1, <> line
1.
Use of uninitialized value in substitution (s///) at -e line 1, <> line
1.
file1 2003-10-10
Use of uninitialized value in regexp compilation at -e line 1, <> line
2.
Use of uninitialized value in substitution (s///) at -e line 1, <> line
2.
file2 2003-10-10
Use of uninitialized value in regexp compilation at -e line 1, <> line
....
....
....
But when I run what was shown in the "echo line" it works just perfectly
on the command-line. It looks like the bash variables won't follow into
the 'perl -ne' command, hence the 'Use of uninitialized value in
substitution' messages.
Does anyone know why and how I can make use of bash variables in that
perl command?
Would be very grateful for any output!
Best regards,
Marcus
- Next message: Douglas Lentz: "Re: command line interface handling asynchronicity"
- Previous message: Drieux: "Re: Sockets and Daemonizing - was Re: Count the no of times a script is called"
- Next in thread: Drieux: "Re: problem using bash variables with command-line perl in bash script"
- Reply: Drieux: "Re: problem using bash variables with command-line perl in bash script"
- Reply: John W. Krahn: "Re: problem using bash variables with command-line perl in bash script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|