Shell / Perl help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell / Perl help
# 1  
Old 08-14-2012
Shell / Perl help

Hi, here is my problem. I have a command line tool to process files. Now I have few hundreds of files to process. So I have written a perl script to generate the command dynamically using variables for the arguments. when I use backtick to execute those it creates error. the shell doesn't get the single command fully, it displays error for part of a single command. So I tried writting these commands in a txt file and tried to execute the command by reading line by line using shell script. But, it also creates problem, when I tried reading a file and execute those commands like "pwd and ls" it executes well. but when I tried to run with the commands I have it displays some other things like glibc detected, backtrace and memory map . Please help me. (the commands I have will take take 3 to 5 mins to complete per command)

---------- Post updated at 01:14 PM ---------- Previous update was at 01:01 PM ----------

This is the error I am getting
Code:
19904 Segmentation fault      (core dumped)


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 08-14-2012 at 09:48 AM.. Reason: code tags
# 2  
Old 08-14-2012
Hi Jith,

You have provided little information here, please try and be a bit more specific. Include things like the version of perl - the operating system, the shell you are using etc. As I'm hoping you're going to respond, what does the code look like and what output do you get from;

Code:
file core

Regards

Dave
# 3  
Old 08-15-2012
Hi, Thanks to both gull04 and the moderator for your comments. I am sorry not to provide sufficient details.

Fortunately I have narrowed down my problem and Im here now :
I am writting a perl script that will run a terminal command and execute something. I this command itself I have @, (, ), \ symbols. when I use backtick perl automatically interpret these things, Now I have escape these characters from perl.
My terminal command is :
Code:
convert_v2 <INPUTFILE_1> -f crop@1920x1079-0+1 -f crop@1920x1080+0+0 -f pixhalf@yonly -f interleave@bottomfield,\( <INPUTFILE_2> -f crop@1920x1080+0+0 -f pixhalf@yinly \) <OUTPUTFILE>

I need to produce the same to be passed to the shell from perl
My perl code is :
Code:
`iconvert_v2 $f1name -f crop\@1920x1079-0+1 -f crop\@1920x1080+0+0 -f pixhalf\@yonly -f interleave\@topfield,\\( $f2name -f crop\@1920x1080+0+0 -f pixhalf\@yonly \\)  $outfil\n`

What I am getting is
Code:
iconvert_v2 FILE1NAME -f cropx1079-0+1 -f cropx1080+0+0 -f pixhalf -f interleave,( FILE2NAME -f cropx1080+0+0 -f pixhalf )  OUTPUTNAME

Can anyone pls help me to get as what I expect. Here the problem is I need perl to interpret only the file name variables nothing else from the command.

---------- Post updated at 02:02 PM ---------- Previous update was at 01:07 PM ----------

Hi thanks fr helping me. I have found a solution for my problem Smilie

This is the correct code to produce the expected one!
Code:
qq!iconvert_v2 $f1name -f crop!.q!@1920x1079-0+1 -f crop@1920x1080+0+0 -f pixhalf@yonly -f interleave@topfield,\(!. $f2name .q!-f crop@1920x1080+0+0 -f pixhalf@yonly \)!." $outfil\n"

# 4  
Old 08-15-2012
For the record, you should never get 'segmentation fault' no matter what you do. That means something very unexpected has happened, to the point the programming language wasn't equipped to handle it.
# 5  
Old 08-15-2012
Quote:
For the record, you should never get 'segmentation fault' no matter what you do. That means something very unexpected has happened, to the point the programming language wasn't equipped to handle it.
Thanks a lot, I have never aware of it!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Shell to PERL

Hi, i must admit that am naive to scripting. I got one shell script created which worked fine on linux. Later i was told that this script is to run on MP-RAS(aka NCR Unix), which is quite an old version of Unix i understand.:wall: in the shell script that i got created, i have made... (6 Replies)
Discussion started by: utkarsh
6 Replies

3. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

4. Shell Programming and Scripting

Shell or Perl?

Hello, I am looking for some basic script help, I am currently tailing a log with a simple tail –f, combined with egrep –vi to remove some messages from the tail, i do not want to see. . I wanted to create something a little more complex were if it’s possible to script this into... (4 Replies)
Discussion started by: hamon
4 Replies

5. UNIX for Dummies Questions & Answers

perl through shell

Can we call a perl script/ commands through a shell script? (1 Reply)
Discussion started by: chn10db001
1 Replies

6. Shell Programming and Scripting

Shell to perl

Hi all experts, I am new to Perl. Could you please help me to convert the following SHELL script to PERL ? I will appreciate. #!/bin/bash #set -x fileday=$1 result_file=Total`date +%Y%m%d%H%M` out_folder=/home/cmd/pm_analyze tmp_folder=/tmp/pmtmp datatype='split licenceCounter... (4 Replies)
Discussion started by: jinanchen
4 Replies

7. Shell Programming and Scripting

Perl Vs Shell Programming

Can someone please tell me what the big deal about perl is? i have been doing shell programming for quite a number of years and I have to say, there's very little if any thing that I can't do in shell programming. i just need to investigate how to do it. so, my question is, does deep... (1 Reply)
Discussion started by: SkySmart
1 Replies

8. Shell Programming and Scripting

Perl - pass shell-vars into perl for input loop

I need to process a file line-by-line using some value from a shell variable Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.) I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies

9. UNIX for Dummies Questions & Answers

shell to perl

hi all, Can we change a shell script into a perl script instead of writing a fresh one in perl? Is there any utility present that can be used for this purpose? please help me. Thanks in advance.. (1 Reply)
Discussion started by: arthi
1 Replies

10. Shell Programming and Scripting

How to Run a shell script from Perl script in Parent shell?

Hi Perl/UNIX experts, I have a problem in running a shell script from my perl script (auto.pl). I run the perl script using perl auto.pl from the shell prompt The shell script picks the files in "input" folder and procesess it. The shell script blue.sh has this code. export... (16 Replies)
Discussion started by: hifake
16 Replies
Login or Register to Ask a Question