Shell directive not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell directive not working
# 1  
Old 11-04-2013
Shell directive not working

Code:
$ cat tmp.sh
#!/tools/bin/bash
echo $BASH_VERSION

Code:
$ cat tmp.pl
#!/usr/local/bin/perl
use strict;
use warnings;
use DBI;
use CGI;

system("tmp.sh");

Code:
$ tmp.sh
3.2.48(1)-release

The result is as expected.
Code:
$ tmp.pl
3.2.25(1)-release

The result is not as expected.
The shell directive in tmp.sh does not work.
Can anybody tell me why?
How to correct it?
Thanks.
# 2  
Old 11-04-2013
Quote:
system() accepts as argument either a scalar or an array. If the argument is a scalar, system() uses a shell to execute the command ("/bin/sh -c command");

If the argument is an array it executes the command directly, considering the first element of the array as the command name and the remaining array elements as arguments to the command to be executed.
So try:

Code:
$ cat tmp.pl
#!/usr/local/bin/perl
use strict;
use warnings;
use DBI;
use CGI;

system("tmp.sh", "");

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 11-05-2013
Quote:
Originally Posted by Chubler_XL
Code:
system("tmp.sh", "");

I don't see how that can possibly make a difference. Whether perl or /bin/sh execs the script, it is the exec(2) syscall that will load the interpreter; in both cases, it will be the same, /tools/bin/bash.

Did I miss something there?

Regards,
Alister
# 4  
Old 11-05-2013
For some reason, the perl script loads a different version of bash than the shell script.
# 5  
Old 11-05-2013
Yes there is something very strange on that server, I wonder what result the OP would get from:

Code:
$ /bin/sh -c tmp.sh

# 6  
Old 11-06-2013
Code:
$ /bin/sh -c tmp.sh
3.2.25(1)-release

I also found another way to solve the issue.
Code:
$cmd="/tools/bin/bash -c 'tmp.sh a b c'";
system($cmd);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Defumask and upload directive in ftp

Hi, I'm aware that this question has been raised earlier and the solution provided has not helped me. So, the issue is that I'm trying to set a defumask to files transferred via ftp to be 002 so that the group may have write permissions to the files uploaded. We have local/system users... (5 Replies)
Discussion started by: maverick_here
5 Replies

2. Ubuntu

Apache - Files directive does not work

HI guys. when i configure Files in this way: <Files ~ "\.png$"> deny from all </Files> it works. but when defining in this way it doesn't work: <Files /var/www/test/file.png> deny from all </Files> directives are not inside Directory directive. Could someone help? (0 Replies)
Discussion started by: majid.merkava
0 Replies

3. Shell Programming and Scripting

Will the scope be there in logrotate after postrotate directive...?

Hi, Please check the below code...:wall: if ; then echo "/var/log/AAA/BBB/xxx_*.log /var/log/AAA/BBB/yyy_*.log {" >> /etc/logrotate.conf echo " weekly" >> /etc/logrotate.conf echo " rotate 10" >> /etc/logrotate.conf... (2 Replies)
Discussion started by: Dedeepthi
2 Replies

4. UNIX for Dummies Questions & Answers

Search directive in resolv.conf

Hi all, I am doing an assignment and there is something I am confused about. The requirement is to set up the DNS and sendmail to two domains: lab1 and lab2, with hosts of mail.lab1 and mail.lab2 both acting as DNS server and email server, and send mail from root@lab1 to root@lab2. However, it... (4 Replies)
Discussion started by: tetelee
4 Replies

5. Web Development

Apache: SSLACARevocation directive issue

I am installing a .crl in my apache config. It looks like this: <VirtualHost default> DocumentRoot "web" ServerName example.com SSLEngine on SSLCertificateFile "cert.crt" SSLCertificateKeyFile "key.key" SSLCertificateChainFile "cert.ca-bundle" SSLProtocol -all +SSLv3... (0 Replies)
Discussion started by: DocBrewer
0 Replies

6. Web Development

regex in apache Allow from directive

Hi, Does the apache Allow from directive support regular expressions? such as: Allow from ^web11blah\.blah\.blah\.yahoo\.com$ what i want to do: allow access from hosts in the range web1160blah.blah.blah.yahoo.com to web1189blah.blah.blah.yahoo.com notice the 1160 to 1189 range as part... (3 Replies)
Discussion started by: Yogesh Sawant
3 Replies

7. Shell Programming and Scripting

vpath directive in make

Hi all, I need to check the contents of my vpath directive in my file. Is it possible to check the contents of the vpath directive as we do for a variable like @echo '$vpath' . Please let me know the above is correct or suggest me the correct one. Thanks in advance. -Jerry (6 Replies)
Discussion started by: jerryragland
6 Replies

8. Programming

Include directive

Hi there, I'm working on a c++ project and I need to use some libraries which are part of a framework. I installed it on my home directory, and alle the .hh are located in subdirs of my home. I'd like to include the files I need just as if they where std c header, that is: #include... (2 Replies)
Discussion started by: clalfa
2 Replies

9. Programming

precompile directive?

hey everyone. havent posted here in a longgggg time. hope to see some familiar faces! heres my question, ive been doing basic programming in c++ again and want to use getch(). in *nix i have to use the curses library, and in windows conio.h is there a way i can have the compiler determine... (2 Replies)
Discussion started by: norsk hedensk
2 Replies

10. UNIX for Dummies Questions & Answers

apache directive only for outside network

I set up a directive for the .htaccess file in one of my web directories. It works fine. Is there a way to force only users outside my internal home network to go through the password authorization? Or, put another way, any user in my network should not have to enter a password. Is that possible? (2 Replies)
Discussion started by: dangral
2 Replies
Login or Register to Ask a Question