run perl script to configure remote computer using sudo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have tried several ways to connect to remote computer:

$SERVER = qx{ssh -o ConnectTimeout=2 -o ControlPersist=yes $user\@$server
"sudo hostname| cut -d "." -f1"}; chomp ($SERVER);

but commands that have metacharacters, especially the single quote, I can not
get to work.

I can run the following from perl after ssh connection with single quotes
included:

$ssh = Net::OpenSSH->new("$user\@$server");
$CMD = "grep -c alias cp='cp -f' /etc/bashrc";
$fh = $ssh->pipe_out($CMD);

while (<$fh>) {
    $OUTPUT .= $_;
}
chomp ($OUTPUT);

and it works.

But if add 'sudo' for cases where I need to read a file that the login user
does not have permissions for -- I can not get it to work.

I have searched and tried a number of recommendations and it either fails with
a permission error or locks up or gives grep errors.

Thanks in advance,

David
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux