473,516 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I'm not able to execute shell command inside the perl script.

13 New Member
This is a txt file
cat msg0008.txt
;
; Message Information file
;
[message]
origmailbox=4031
context=Context_Test
duration=10

basically i want to cut 4031 from msg0008.txt

There is piece of code in perl

Expand|Select|Wrap|Line Numbers
  1. foreach $file (@change_dir)
  2. {
  3.         if (-d $file)
  4.                 {
  5.                  $file_dir = "/var/spool/asterisk/voicemail/default/$file/INBOX";
  6.                  chdir("$file_dir");
  7.                  $chek_wav = `find $file_dir -amin -3 -name "*.wav"|wc -l`;
  8.                  system("cd");
  9.  
  10.          if($chek_wav != 0)
  11.        {
  12.  
  13. for($i=0;$i<=$chek_wav;$i++)
  14.                 {
  15.  
  16.         @txt_format=`find /var/spool/asterisk/voicemail/default/$file/INBOX -amin -3 -name "*.txt"`;
  17.  
  18.         $txt_file=$txt_format[$i];
  19.  
  20.         $origmailbox=`sed -n '5p' $txt_format[$i]| cut -c 13-16`;
  21.  
  22.         print "$origmailbox\n" ;
  23.  
  24.                 }
  25.  
  26.         }
  27.  
  28.                 }
  29. }
whenever i will execute this code i got error in following line

$origmailbox=`sed -n '5p' $txt_format[$i]| cut -c 13-16`;

error :
origmailbox=4031
sh: -c: line 1: syntax error near unexpected token `|'
sh: -c: line 1: `| cut -c 13-16'
512
Jul 26 '12 #1
1 2076
RonB
589 Recognized Expert Moderator Contributor
Have you tried adding a space between the var and the pipe?

Why all the backticks commands when Perl has its own methods of doing the same things without needing to fork sub processes?
Jul 26 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
9746
by: lecichy | last post by:
Hello. As in the topic, I use www to execute shell command, in this case 'ls -l' and i get output like: total 8 drwx------ 11 lecichy staff 4096 Oct 15 18:18 Maildir drwx---r-x 3 lecichy staff 4096 Oct 13 19:28 public_html etc. but what If i would want to print to www only some columns. e.g. only
3
3875
by: Paul | last post by:
Hi, I'm a Python newbie and I'm wondering how I can do the following Perl thing: open(F, 'grep -b 2004 logfile | head -1 | cut -d: -f1 |') or die "blah, blah"; $offset = <F>; ( or $offset = `grep -b 2004 logfile | head -1 | cut -d: -f1`; ) in Python. When I tried:
4
9873
by: Kartik | last post by:
Hi, I have an ASP.NET application using VB.NET.I am sending a DOS command to a machine on the network to print a file. This is achieved using xp_cmdshell Dim str As String = "xp_cmdshell ""type " & nwkfilepath & " > " & pPrinterName & " """
2
6933
by: ¹é¿ø¼® | last post by:
Hello, everybody. I want to call any shell command from php script using shell_exec(). The problem is that the next line of the php script would not be run until a few minutes after running the shell command. I found the shell command couldn't be run at background mode. It seemed that the shell_exec() function waits a return from the...
9
35983
by: skyy | last post by:
Hi i am trying to use the system() command to run some linux command using perl script... Eg.. Deleting files. system("rm $filename"); However, when my $filename contain " character, the sommand wont work. Any idea how to go around this?
9
19977
rajiv07
by: rajiv07 | last post by:
Hi to all, I want execute a perl program inside another perl program with passing some values to called program by calling program. Is any Idea please. Thanks in advance.
4
19670
by: jram01 | last post by:
Hi Folks, I am facing problem to to execute .sql command in sql prompt using perl script. I am able to connect sql promt using " my $odbcinput = "odbcinput.txt"; my $odbcoutput = "odbcoutput.txt"; open (ODBCSQLFH, ">$odbcinput") || die "Unable to create input file ($odbcinput) for odbcsql\n";
1
6491
by: Raju Sathliya | last post by:
Hi, I need to run Perforce command from perl script but it gives me error as per below: Can't locate P4.pm in @INC (@INC contains: C:\build\software\Perl\perl5.00402\lib\site ...... my perl script is as per below: -------------------------------------------------------------------------- #!/usr/bin/perl use P4;
16
4047
rahuljaiswal1987
by: rahuljaiswal1987 | last post by:
Videoagent.exe -s 100.100.10.1 -c 3 -d 08252002 -b 14:12:35 -e 14:15:12 -u USERID -p PASSWORD This is a command to execute video agent with these parameter. I want to execute this command through javascript. Tell me some solution if you have.
4
5944
by: lilly07 | last post by:
I am trying to use a shell grep command inside a perl script using system command as below. system "cat $source_path/s_${i}_${j}_0*testing.txt | grep ' $1' | head > $path/s_${i}_${j}.txt"; I am trying to grep for lines that ends with 1 inside the system command. system command concatenates everything and writing into output file...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.