• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

system

i cannot use variable in system command
system('scp  /u/rshah1/www/out-of-service/$filename rshah1@sdm1:/olanfs00/u/rshah1/spam');

if i replace $filename with the actual fiilename temp.txt ....... it works fine

i also tried system " blah ...... " ---------------- even this is not working
0
shahrahulb
Asked:
shahrahulb
3 Solutions
 
_kiewCommented:
Use:

system("scp  /u/rshah1/www/out-of-service/$filename rshah1\@sdm1:/olanfs00/u/rshah1/spam");

(notice double quotes and \@)
0
 
shahrahulbAuthor Commented:
why can't i run the following command from cgi
system ("ssh sdm .........")

it works fine if run the script as .pl
0
 
stefan73Commented:
Hi shahrahulb,
> why can't i run the following command from cgi
> system ("ssh sdm .........")

Maybe your ssh command requires interactivity (i.e., entering a password, or just a tty)?

Cheers!

Stefan
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ozoCommented:
ssh would use the user id you are running it from.
You probably have permissions on the remote system that the CGI user does not.
0
 
stefan73Commented:
Yes, change to the CGI user and see if it can do ssh. You can only use a plain hostname when you have configured ssh to have a default user for the target system. And also make sure the target account has the CGI user's public key.

Stefan
0
 
manav_mathurCommented:
shahrahulb,
Is it a continuation of the previous question that involved me and Kandura??

If yes, then
- the ssh keys created were passphraseless.
- the ssh keys created were for the httpd user
- private key, stored in a destinaiton, accessible only by httpd
- public key, stored on the second system, looks to be accessible by rshah1 user.

Manav
0
 
nOOgzCommented:
try this:

my @args = ("scp", "/u/rshah1/www/out-of-service/$filename", "rshah1\@sdm1:/olanfs00/u/rshah1/spam");
system(@args) == 0
    or die "system @args failed: $?"

this will fix your problem, but you will also be asked to enter the password, in case you haven't
set up ssh to allow you to log in without a password.

hope this helps,
thorsten.
0
 
manav_mathurCommented:
jmcg,

I think I do not deserve points here. I remember having solved a similar problem for the same asker and the question looked like a continuation of the previous one. I have just mentioned few specifics which I thought would help the other experts get a better understanding of the question.

Manav
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now