473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

strange behavior with system()

Hi,

I have a strange problem with the system() function in perl.

system("source new_script.csh") == 0 or die "$? Call failed : $!\n";

The shell complains "No such file or directory".

Now if i change that line to
system("ls;source new_script.csh") == 0 or die "$? Call failed : $!\n";

it starts sourcing the file.

But even though it sources the file, the shell gives out errors like
sh : setenv : Command not found

(The first line of new_script.csh reads #!/bin/tcsh, so it should use the right shell).

Does anyone have any ideas on what the problem might be ?

Thanks
-
Sep 25 '07 #1
5 4136
numberwhun
3,509 Expert Mod 2GB
Hi,

I have a strange problem with the system() function in perl.

system("source new_script.csh") == 0 or die "$? Call failed : $!\n";

The shell complains "No such file or directory".

Now if i change that line to
system("ls;source new_script.csh") == 0 or die "$? Call failed : $!\n";

it starts sourcing the file.

But even though it sources the file, the shell gives out errors like
sh : setenv : Command not found

(The first line of new_script.csh reads #!/bin/tcsh, so it should use the right shell).

Does anyone have any ideas on what the problem might be ?

Thanks
-
First, try changing the double quotes to single quotes. Second, use the absolute path to the file.

Regards,

Jeff
Sep 25 '07 #2
First, try changing the double quotes to single quotes. Second, use the absolute path to the file.

Regards,

Jeff
I tried that :

system('source /projects/test/new_script.csh');

still has a problem.

If I add an ls,
system('ls;source /projects/test/new_script.csh');

it seems to source it.

Thanks
Sep 25 '07 #3
I tried that :

system('source /projects/test/new_script.csh');

still has a problem.

If I add an ls,
system('ls;source /projects/test/new_script.csh');

it seems to source it.

Thanks
Ok.
Looks like it should be
system('source "myfile.csh"')
OR
system ("source \"myfile.csh\"");

I still couldnt figure out why the setenvs dont work.
Sep 25 '07 #4
numberwhun
3,509 Expert Mod 2GB
Ok.
Looks like it should be
system('source "myfile.csh"')
OR
system ("source \"myfile.csh\"");

I still couldnt figure out why the setenvs dont work.
Well, there is always doing it in shell (granted that would defeat the purpose of you doing it in Perl if you have a goal).

Regards,

Jeff
Sep 25 '07 #5
Well, there is always doing it in shell (granted that would defeat the purpose of you doing it in Perl if you have a goal).

Regards,

Jeff
Yes, thats true. Actually the entire thing was originally written in C shell. I wrote the perl program as a master program that would do all the difficult stuff, and then spit out a .csh file which I could then source.

Anyway, it looks like when I do a source, the shell is somehow a bash (or variant) shell, because "export VAR=value" didnt complain but "setenv VAR value"
complains.

(when I do a echo $SHELL inside the .csh file, it prints out /bin/tcsh though)
Sep 25 '07 #6

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

Similar topics

36
by: Dmitriy Iassenev | last post by:
hi, I found an interesting thing in operator behaviour in C++ : int i=1; printf("%d",i++ + i++); I think the value of the expression "i++ + i++" _must_ be 3, but all the compilers I tested...
0
by: globus | last post by:
Hi, I've a c# project calling a COM Interop library method. This method starts a Service , so I need administrator or power user rights to use it without exceptions. I'm developing exceptions...
0
by: the friendly display name | last post by:
Hi, I have a filled multiline textbox on the site. I can scroll it with IE and Firefox, but under Opera (tested under 7.54, and Opera 8, under "identify as MSIE" and under Opera identification)...
7
by: Tyler Foreman | last post by:
Hello, I have a strange problem that occurs every so often in my application. It usually takes place when I hide one form and activate another. What happens is I get the following exception:...
1
by: hansolox1 | last post by:
The following program simply sets the icon of a form called form1. When I get the name of the embedded icon using GetManifestResourceNames(), I store the name in a string variable called s. The...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
2
by: Antonio | last post by:
Good morning, everyone. Here is the strange behavior: I have a datagrid (dgPIs) with paging enabled. When I click to view any page in the grid, it runs the private void lnkIPReg method,...
3
by: senfo | last post by:
I developed a Windows control in VS 2005 that inherits from the PictureBox Control that adds the ability to select images in a Windows application. It is, however, experiencing a strange issue...
10
by: John Kraft | last post by:
Hello all, I'm experiencing some, imo, strange behavior with the StreamReader object I am using in the code below. Summary is that I am downloading a file from a website and saving it to disk...
8
by: FBM | last post by:
Hi there, I am puzzled with the behavior of my code.. I am working on a networking stuff, and debugging with eclipse (GNU gdb 6.6-debian).. The problem I am experiencing is the following: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.