Sponsored Content
Top Forums Shell Programming and Scripting Perl : Global symbol requires explicit package name Error while executing Post 302785759 by scriptscript on Tuesday 26th of March 2013 10:22:24 AM
Old 03-26-2013
Perl : Global symbol requires explicit package name Error while executing

I have executed the below perl script for copying the file from one server to another server using scp.

Code:
#!/usr/bin/perl -w
use Net::SCP::Expect;
use strict;
$server= "x.x.x.x";
my $source = "/mypath/mypath";
my $destination = "/home/";
print "Login...Starting scp...";
$user="admin";
$password="admin";
print "Login...Starting scp...";
my $scpe = Net::SCP::Expect->new(host=>$server, user=>$user, password=>$password, recursive=>'1', auto_yes => '1', auto_quote => '0');
$scpe->scp('x.x.x.x:/mypath/*.csv',$destination);
print "SCP complete\n";

But I have received the below errors
Code:
DC01INETSRV2[Johng]/s0/home>perl sftptest.pl
Global symbol "$server" requires explicit package name at sftptest.pl line 11.
Global symbol "$user" requires explicit package name at sftptest.pl line 15.
Global symbol "$password" requires explicit package name at sftptest.pl line 16.
Global symbol "$server" requires explicit package name at sftptest.pl line 20.
Global symbol "$user" requires explicit package name at sftptest.pl line 20.
Global symbol "$password" requires explicit package name at sftptest.pl line 20.
Execution of sftptest.pl aborted due to compilation errors.

COuld anyone please help me on the above errors.

Thanks in advance...

Regards,
J
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

SFTP error:-b requires an argument greater than zero

Hi when i execute the below command sftp -b ftpCommand.ksh remoteuser@remoterserver i am getting the error "-b requires an argument greater than zero" Please can any one help me. (1 Reply)
Discussion started by: vgs
1 Replies

2. Shell Programming and Scripting

SFTP error:-b requires an argument greater than zero

Hi when i execute the below command sftp -b ftpCommand.ksh remoteuser@remoterserver i am getting the error "-b requires an argument greater than zero" Please can any one help me. (4 Replies)
Discussion started by: vgs
4 Replies

3. Shell Programming and Scripting

change requires with perl

Hi, i need to change a file with perl having contents below, but it will not do any action if change is being already made. file.txt AAAAAA BBBBBB CCCCCC output.txt (that required) AAAAAA #BBBBB DDDDDD CCCCCC Thanks, (2 Replies)
Discussion started by: learnbash
2 Replies

4. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

5. Shell Programming and Scripting

Error in executing Perl script

Hello All I am facing an issue The unix script is running fine in unix environment which uses ssh connection but when I try to run the same in informatica environment (same server where I was running the unix script manually successfully) its showing the below error command-line line 0:... (11 Replies)
Discussion started by: Pratik4891
11 Replies

6. UNIX for Dummies Questions & Answers

Can't install rpm package with --prefix in new path.Error: package is not relocatable

Hello, i have downloaded an rpm package "hadoop-0.20.205.0-1.amd64.rpm" in /usr/local/ directory. I'm trying to install the rpm package in a new path/location (/usr/local/hadoop-0.20.205), but i can't. I did: 1st try: Didn't work sudo rpm -i --prefix=/usr/local/hadoop-0.20.205... (1 Reply)
Discussion started by: g_p
1 Replies

7. Emergency UNIX and Linux Support

Problem when trying to remove a package using rpm command - error: package is not installed

Hello, i have installed a package by using the command sudo rpm -i filepackage.rpm package filepackage is already installed when i try to remove it, i get an error saying "is not installed": sudo rpm -e filepackage.rpm error: package filepackage is not installed How can... (4 Replies)
Discussion started by: g_p
4 Replies

8. Shell Programming and Scripting

Perl : meaning of ||= symbol

While going through the below perl code, there is a line which contains $sheet -> {MaxRow} ||= $sheet -> {MinRow}; Could anyone please explain the meaning of ||= and where it is used complete code --------------- foreach my $sheet (@{$excel -> {Worksheet}}) { ... (2 Replies)
Discussion started by: giridhar276
2 Replies

9. Shell Programming and Scripting

Executing perl script in Linux gives :Exec format error. Wrong Architecture

i have perl script that used to be working great , once i edit it in windows and convert it to UTF-8 and then via FTP return it . also did: chmod +x foo.pl and then when i try to run it : ./foo.pl im getting this error: ./foo.pl: Exec format error. Wrong Architecture.... (4 Replies)
Discussion started by: umen
4 Replies

10. Solaris

Global zone has an older version of package: pkg://Solaris/system/library

I try to install php-56 in a zone, but I have the following problem: pkg install php-56 Creating Plan (Running solver): \ pkg install: No solution was found to satisfy constraints maintained incorporations: None Creation Plan: dependency error (s) in proposed packages: Not... (0 Replies)
Discussion started by: ymk369
0 Replies
SCP(3pm)						User Contributed Perl Documentation						  SCP(3pm)

NAME
Net::SCP - Perl extension for secure copy protocol SYNOPSIS
#procedural interface use Net::SCP qw(scp iscp); scp($source, $destination); iscp($source, $destination); #shows command, asks for confirmation, and #allows user to type a password on tty #OO interface $scp = Net::SCP->new( "hostname", "username" ); #with named params $scp = Net::SCP->new( { "host"=>$hostname, "user"=>$username } ); $scp->get("filename") or die $scp->{errstr}; $scp->put("filename") or die $scp->{errstr}; #tmtowtdi $scp = new Net::SCP; $scp->scp($source, $destination); #Net::FTP-style $scp = Net::SCP->new("hostname"); $scp->login("user"); $scp->cwd("/dir"); $scp->size("file"); $scp->get("file"); DESCRIPTION
Simple wrappers around ssh and scp commands. SUBROUTINES
scp SOURCE, DESTINATION Can be called either as a subroutine or a method; however, the subroutine interface is depriciated. Calls scp in batch mode, with the -B -p -q and -r options. Returns false upon error, with a text error message accessable in $scp->{errstr}. Returns false and sets the errstr attribute if there is an error. iscp SOURCE, DESTINATION Can be called either as a subroutine or a method; however, the subroutine interface is depriciated. Prints the scp command to be execute, waits for the user to confirm, and (optionally) executes scp, with the -p and -r flags. Returns false and sets the errstr attribute if there is an error. METHODS
new HOSTNAME [ USER ] | HASHREF This is the constructor for a new Net::SCP object. You must specify a hostname, and may optionally provide a user. Alternatively, you may pass a hashref of named params, with the following keys: host - hostname user - username interactive - bool cwd - current working directory on remote server login [USER] Compatibility method. Optionally sets the user. cwd CWD Sets the cwd (used for a subsequent get or put request without a full pathname). get REMOTE_FILE [, LOCAL_FILE] Uses scp to transfer REMOTE_FILE from the remote host. If a local filename is omitted, uses the basename of the remote file. mkdir DIRECTORY Makes a directory on the remote server. Returns false and sets the errstr attribute on errors. (Implementation note: An ssh connection is established to the remote machine and '/bin/mkdir -p' is used to create the directory.) size FILE Returns the size in bytes for the given file as stored on the remote server. Returns 0 on error, and sets the errstr attribute. In the case of an actual zero-length file on the remote server, the special value '0e0' is returned, which evaluates to zero when used as a number, but is true. (Implementation note: An ssh connection is established to the remote machine and wc is used to determine the file size.) put LOCAL_FILE [, REMOTE_FILE] Uses scp to trasnfer LOCAL_FILE to the remote host. If a remote filename is omitted, uses the basename of the local file. binary Compatibility method: does nothing; returns true. quit Compatibility method: does nothing; returns true. FREQUENTLY ASKED QUESTIONS
Q: How do you supply a password to connect with ssh within a perl script using the Net::SSH module? A: You don't (at least not with this module). Use RSA or DSA keys. See the quick help in the next section and the ssh-keygen(1) manpage. A #2: See Net::SCP::Expect instead. Q: My script is "leaking" scp processes. A: See "How do I avoid zombies on a Unix system" in perlfaq8, IPC::Open2, IPC::Open3 and "waitpid" in perlfunc. GENERATING AND USING SSH KEYS
1 Generate keys Type: ssh-keygen -t rsa And do not enter a passphrase unless you wanted to be prompted for one during file copying. Here is what you will see: $ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/User/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/User/.ssh/id_rsa. Your public key has been saved in /home/User/.ssh/id_rsa.pub. The key fingerprint is: 5a:cd:2b:0a:cd:d9:15:85:26:79:40:0c:55:2a:f4:23 User@JEFF-CPU 2 Copy public to machines you want to upload to "id_rsa.pub" is your public key. Copy it to "~/.ssh" on target machine. Put a copy of the public key file on each machine you want to log into. Name the copy "authorized_keys" (some implementations name this file "authorized_keys2") Then type: chmod 600 authorized_keys Then make sure your home dir on the remote machine is not group or world writeable. AUTHORS
Could really use a maintainer with enough time to at least review and apply patches more patches. Or the module should just be deprecated in favor of Net::SFTP::Expect or Net::SFTP::Foreign and made into a simple compatiblity wrapper. Ivan Kohler <ivan-netscp_pod@420.am> Major updates Anthony Deaver <bishop@projectmagnus.org> Thanks to Jon Gunnip <jon@soundbite.com> for fixing a bug with size(). Patch for the mkdir method by Anthony Awtrey <tony@awtrey.com>. Thanks to terrence brannon <tbone@directsynergy.com> for the documentation in the GENERATING AND USING SSH KEYS section. COPYRIGHT
Copyright (c) 2000 Ivan Kohler Copyright (c) 2007 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. BUGS
Still has no-OO cruft. In order to work around some problems with commercial SSH2, if the source file is on the local system, and is not a directory, the -r flag is omitted. It's probably better just to use OpenSSH <http://www.openssh.com/> which is the de-facto standard these days anyway. The Net::FTP-style OO stuff is kinda lame. And incomplete. iscp doesnt expect you to be logging into the box that you are copying to for the first time. so it's completely clueless about how to handle the whole 'add this file to known hosts' message so it just hangs after the user hits y. (Thanks to John L. Utz III). To avoid this, SSH to the box once first. SEE ALSO
For a perl implementation that does not require the system scp command, see Net::SFTP instead. For a wrapper version that allows you to use passwords, see Net::SCP::Expect instead. For a wrapper version of the newer SFTP protocol, see Net::SFTP::Foreign instead. Net::SSH, Net::SSH::Perl, Net::SSH::Expect, Net::SSH2, IPC::PerlSSH scp(1), ssh(1), IO::File, IPC::Open2, IPC::Open3 perl v5.10.0 2007-10-26 SCP(3pm)
All times are GMT -4. The time now is 10:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy