exec perl in expect script yields "invalid command"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting exec perl in expect script yields "invalid command"
# 1  
Old 01-11-2012
exec perl in expect script yields "invalid command"

I'm trying to execute something like this:
Code:
exec perl -i -pe 's/\015/\012/g' '${file}'

in my expect script and I get:
Code:
error "invalid command name \"perl\".

however, if I run
Code:
perl -i -pe 's/\015/\012/g' "/Users/Shared/menu-items.txt"

directly in my terminal, it runs fine. I'm an exec/shell novice, so hopefully this is an easy one. Any help is much appreciated!


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 01-12-2012 at 04:55 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 01-11-2012
Try without exec in script.
# 3  
Old 01-11-2012
I removed exec, so the line is now:

Code:
perl -i -pe 's/\015/\012/g' "/Users/Shared/menu-items.txt"

error "invalid command name \"perl\"

while executing...

Last edited by Franklin52; 01-12-2012 at 04:56 AM.. Reason: Please use code tags for code and data samples, thank you
# 4  
Old 01-12-2012
execute the below command

Code:
 
which perl

and you will get a output like /bin/perl or something....

then replce the perl with the absolute path of "which perl" output
# 5  
Old 01-12-2012
Code:
/usr/bin/perl -i -pe 's/\015/\012/g' "/Users/Shared/menu-items.txt"

error "invalid command name \"/usr/bin/perl\"
    while executing
\"/usr/bin/perl -i -pe 's/\\015/\\012/g' \"/Users/Shared/menu-items.txt\"\"

Perhaps the error is too vague. Maybe it doesn't like something else about the syntax (even though that one line runs fine in the terminal)

Last edited by Scott; 01-12-2012 at 10:40 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Expect: spawn id exp5 not open while executing "expect "$" { send "sudo su -\r" }"

Hi All, i am trying to ssh to a remote machine and execute certain command to remote machine through script. i am able to ssh but after its getting hung at the promt and after pressing ctrl +d i am gettin the out put as expect: spawn id exp5 not open while executing "expect "$" {... (3 Replies)
Discussion started by: Siddharth shivh
3 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

"exec" command. Stopoutput to file.

I have a script (ksh, Linux) which is about 500 lines and this is only a small requirement. Below is an example of my requirement. FunctionThis(){ echo "You are in this. Goes to log" } FunctionThat(){ echo "You are in That. Goes to log" } FunctionScreen(){ echo "You are in Screen.... (3 Replies)
Discussion started by: edidataguy
3 Replies

5. Shell Programming and Scripting

A question on "exec" command

The following is my bash script ----------------------- #!/bin/bash exec myscript "$@" ----------------------- When invoked, the script "myscript" in the exec command is using the file "/usr/bin/diff" But, I want the script "myscript"to use the file "/home/bin/diff" How can I... (1 Reply)
Discussion started by: bsoo
1 Replies

6. Shell Programming and Scripting

Perl "Invalid argument error"

Hi , we have a issue in server, we are running a perl script to connect our clients, but we are not able to connect, every time we are getting the "Invalid argument error" Even i checked all the necessary perl modules are i installed in this server, #create the listen socket my... (2 Replies)
Discussion started by: anishkumarv
2 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Send "perl -e '...' " command through SSH, from a perl script

Hey guys I am trying to send a perl -e command to a number of systems using SSH. The command should retrieve some information for me. The problem is, the remote shell tries to interpolate my variables and doesn't get it should take the command literally and just execute it. Below the code.... (2 Replies)
Discussion started by: clrg
2 Replies

9. Shell Programming and Scripting

question about "sleep" command in expect script

I wrote some expect script to telnet to some device to execute some commands.Firstly,I can't get full result some time,then I try to add some "sleep" command in it.Fortunately it works. My idea about it is that it uses sleep command to wait the result to be displayed.Am I right or correct the... (4 Replies)
Discussion started by: robbiezr
4 Replies

10. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question