Hope everyone is fine
I have this code below:
When I tried to execute it, found an error which looks like this below:
What is the meaning of this error and how can I make my script work? Please advise.
Given what you've shown, I'd say you just need to wrap your vars with single quotes when they're used; ie, '$var'. This may not be it, as it's balking at barewords, but it allows for the proper shell-out that you'd defined...but then again given what we've seen, if that's the extent of your script, why not just leave it as a shell script? Perl isn't even needed under the circumstances.
Thanks for the info, for now I've already created one using shell script this time. The script is now working and later I will put it in CRON.
Our server can only accept CRON entries provided you're a root user, so I've tried to input the script as a root user, my problem is that it's not functioning. Here is the analogy below:
Files that I want to remove are located in /home/user/USER_LOGS/, the script is also located in this directory. This is the script:
but as per running the script when I'm in the directory /root (this is the default directory upon login as root user), it can't see the file and therefor it can't perform the rm function. This is what I've did as root user:
I think the problem here is that it can't locate the files that I want to delete under the /root directory. Can you help me how to enhance my script so that if ever I would like to put it in CRON it will function normally, by removing file on top and retaining only 3 files on it.
Please advice,
rymnd_12345
Last edited by vbe; 01-04-2012 at 12:30 PM..
Reason: code tag correction...
your file list includes some info from the long listing (ls -lrt) by accident ... confirm by running the code below by itself ...
... use "ls -rt" instead of "ls -lrt" ...
Hi All,
I got some requirement of using Awk in perl subroutine
One of the variable in my perl script holds below type of data.
I want to split this value as quotes seperated and get the second last field i.e., 3206000 from above.
I used below code in my perl sub-routine,... (3 Replies)
Hi all;
I have a Perl script that uses this awk command wrapped in a "system" call; it works exactly as I want it; however I want to keep this a Perl script and have very few if any "system" command...so the question; can someone help me code this in Perl please ... i have tried an now I am... (1 Reply)
Hi,
I have an array with following data. First field shows the owner and second is unique name. Now i have to pic the latest value with respect to the date in case of duplicate.
like "def" is from two owners "rahul/vineet", now i want the latest from the two and the owner name also for all the... (9 Replies)
i have two files as shown below
t1.txt:
argument1
argu2
argu37
t2.txt:
22
33
44
i want o/p as
argument1 22
argu2 33
argu37 44
i am trying to merge two file under perl script using following
system("paste t1.txt t2.txt | awk... (3 Replies)
Hello experts
I want to execute a awk command, which reads from txt files and sums the numbers from the first column for those listed only inside a <init> block -- The awk command is like
awk '/<\/?init>/{x = !x}x{a++}x && a > 2{sum+=$1}END{printf"%E" "\n", sum}
So, I want to execute... (2 Replies)
Hi,
Can some one please tell me how to redirect only errors to the log file using perl.
Thanks,
Anjan.
---------- Post updated at 08:41 PM ---------- Previous update was at 08:39 PM ----------
Also, i dont want to use any module. Please tell me in normal way (1 Reply)
When trying to use backticks for system commands, is there a way to read the error messages if a command doesn't execute properly?
I have no problem getting the results if the command is properly executed.
Ex.
my @result = `dir`;
foreach my $line (@result) {
print "Result = $line";... (2 Replies)
Hi,
I am a newbie to PERL and working on a script. When running it I get a lot of compilation errors.
The actual command in the program (which is within a case structure) is given below
# This gives the actual count of inquires from a log file (It works fine when I type this on the... (2 Replies)
Hi All,
My Input file looks like below:
Input:
100,200,300
$fw=`head -1 test.csv | awk -F, '{print \$1}'`;
$fw="'$fw"
$fw="$fw'"
print $fw
Output:'100'
I want the first field to be printed in single quotes ('') like above.
I could get the ouptput but the problem is single... (6 Replies)