Perl system() to run a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl system() to run a script
# 8  
Old 08-27-2013
the fact that it works outside the perl script with apache user, I believe it should work inside the script as well. May be try pushing the STDERR to the file that you are writing and check if the file has any pointers to error. Try making file to /tmp/test.css to ensure that writing part if not failing.

Code:
$cmd = qq(/path/to/csso stylesheet.css > /tmp/stylesheet.min.css 2>&1)
system($cmd);

This User Gave Thanks to rajamadhavan For This Post:
# 9  
Old 08-27-2013
Thanks, that was helpful!

/usr/local/bin/csso: line 13: node: command not found

It needs node.js, but it looks like it can't find it. I'll try to see how to fix it.

EDIT: I modified csso binary file and where it called:
node
I added:
/usr/local/bin/node

It's working perfectly. Thank you very much!

Last edited by madispuk; 08-27-2013 at 09:50 AM..
# 10  
Old 08-27-2013
The correct thing to do in this case, instead of altering binary programs with a hex editor, is to add /usr/local/bin to your PATH environment variable so the system can find these things without hardcoded paths.
# 11  
Old 08-27-2013
Thank you Corona688 for you reply.
This binary wasn't really a binary, it was just in the /bin folder, so I could just change the code without using hex editor.
/usr/local/bin is in the PATH when I run:
set
If my script calls perl system() from the web interface, and apache is the user who runs it, it doesn't see these PATH variable. Does it have it's own ENV variables? Can you tell me how I can change apache ENV variables?
# 12  
Old 08-27-2013
Quote:
Originally Posted by madispuk
If my script calls perl system() from the web interface, and apache is the user who runs it, it doesn't see these PATH variable. Does it have it's own ENV variables? Can you tell me how I can change apache ENV variables?
Every process that runs has its own environment variables. Your perl script can alter its own environment variables via the ENV hash, i.e. $ENV{"PATH"}
This User Gave Thanks to Corona688 For This Post:
# 13  
Old 08-27-2013
Thank you for your reply! I can make correct modifications now.

Moderator's Comments:
Mod Comment Please use CODE tags not CODE tags for your posts
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

3. Shell Programming and Scripting

Run shell script on different machine using perl script

I want to execute my shell script on remote machine using SSH in perl script. Please help me with syntax. (2 Replies)
Discussion started by: james1988
2 Replies

4. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

5. Shell Programming and Scripting

Run script from another script if system date was reached

I what to find a system date in a shell script and search for it in a file in specific record. If the record (ENDC) has the same date I what to execute another shell script. Here is example of the file: Can someone please help me with this ? (3 Replies)
Discussion started by: Lenora2009
3 Replies

6. Shell Programming and Scripting

how to let the perl script to run for each file

Hi, I have more than 1 files in the directory. In bash, I can use cd /work for x in `ls` do : : done to run for each file in the directory. How about in perl script? filepath="ABC1" open(FILE, $filepath) or die "$filepath cannot be opened."; while(<FILE>) { : (1 Reply)
Discussion started by: natalie23
1 Replies

7. Shell Programming and Scripting

Run system command in perl cgi

Hi guys, got a problem with a perl cgi script over here. I need it to run a system command to get the status of a process. Unfortunately the process is owned by a specific user and only this user can get its status. So i tried running the command from the perl cgi with "su", but then i get the... (12 Replies)
Discussion started by: polki
12 Replies

8. Shell Programming and Scripting

Run Shell Script on Remote System

I honestly tried searching for this in this forum and in google. Maybe I found the answer but didn't even realized it. I would like to run shell script thats on my machine that collects the hostname and IP address from the remote system and sends the output to my machine. I'm not sure if need... (2 Replies)
Discussion started by: elbombillo
2 Replies

9. Shell Programming and Scripting

Perl: Run perl script in the current process

I have a question regarding running perl in the current process. I shall demonstrate with an example. Look at this. sh-2.05b$ pwd /tmp sh-2.05b$ cat test.sh #! /bin/sh cd /etc sh-2.05b$ ./test.sh sh-2.05b$ pwd /tmp sh-2.05b$ . ./test.sh sh-2.05b$ pwd /etc sh-2.05b$ So... (10 Replies)
Discussion started by: vino
10 Replies

10. Shell Programming and Scripting

Perl run system command

Can perl execute a system command similar to the C function System()? Thanks. Gregg (1 Reply)
Discussion started by: gdboling
1 Replies
Login or Register to Ask a Question