Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Error when running script involving machine name and local network Post 303044858 by honeyhamlet on Thursday 5th of March 2020 10:57:53 AM
Old 03-05-2020
Error when running script involving machine name and local network

Hi everyone, I'm trying to write a script that takes a machine name as a command line argument and displays a message informing me whether the host is on the local network.

Here's what I have:

Code:
#!/bin/bash
gateway=$(ip route | grep default | cut -d' ' -f3)

if [[ $(ip route get "$1" | grep -q $gateway) ]]; then

echo "$1 is on the local network"

else

echo "$1 is not on the local network"

fi

Whenever I run it with my machine name (ubuntu) I get the following output:

Code:
Error: any valid prefix is expected rather than "ubuntu".
ubuntu is not on the local network

I'm not sure what the error means and why I'm getting it, as well as if the script is even doing what it should be doing. Any advice would be appreciated. Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing shell script on local machine

Hi guys, I need to run and test some shell script. At work, i work on ksh. I don't have any such software/client installed at home and i cannot always connect to work from home. At home i have Windows Vista. Is there a free and reliable software where i can run my ksh script? Please let me... (4 Replies)
Discussion started by: jakSun8
4 Replies

2. Red Hat

To find the LATEST file from a dir on REMOTE machine and SCP to local machine?

Hi All, URGENT - Please help me form a scipt for this: I need the LATEST file from a dir on REMOTE machine to be SCP'd to a dir on local machine. (and I need to execute this from local server) I know that the below cmd is used to find the LATEST file from a dir. But this command is not... (3 Replies)
Discussion started by: me_ub
3 Replies

3. Shell Programming and Scripting

check web server running on local and on remote machine

Hi , How to check whether web server is running from remote machine How to check whether web server is running on web server itself Can any one help me soon (1 Reply)
Discussion started by: satheeshkr_cse
1 Replies

4. Programming

shell scripting problems involving operations with remote machine

Hi, i have been developing a shell script to transfer a set of files from one ubuntu system to another. Task: while executing the script the files ( ls, dir, cat) in the source machine should transfer to destination machine(at /home/mac/mac/bin) While the script is executed once again, It... (0 Replies)
Discussion started by: srijith
0 Replies

5. Shell Programming and Scripting

How to transfer files from unix machine to local machine using shell script?

Hi All.. Am new to Unix!! Am creating a shell script in which a scenario is like i have transfer the output file from unix machine (Server) to local directory (Windows xp). And also i have to transfer the input file from the local directory to Unix machine (Server) Any help from you... (1 Reply)
Discussion started by: vidhyaS
1 Replies

6. UNIX for Advanced & Expert Users

FTP While transfering files to local machine to remote machine

Hi Am using unix Ksh Am getting the problem while transferring zero size files through the script . When i transfer zero size files from local machine to remote machine manually i can able to do it . My question its beause of zero size files am not able to transfer through script ? or its... (2 Replies)
Discussion started by: Venkatesh1
2 Replies

7. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

8. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

9. Shell Programming and Scripting

Help with fetching the data from remote machine from my jumpbox(local machine)

Team, Presently i am running a script from my local box(i.e jumpbox) to all the remote machines.Basically fetching basic queries like pwd,mkdir,touch etc and i am able to successfully fetch it from my local machine.But when i want to check certain database related queries like the dbstat... (20 Replies)
Discussion started by: whizkidash
20 Replies

10. Shell Programming and Scripting

How can I execute local script on remote machine and include arguments?

I have a script in local server cd /home/dell/work/BOP/testdir ./processchk po (here processchk is a script & po is passed as an argument) Now I want to execute this script from remote server ssh $username@$hostname "cd /home/dell/work/BOP/testdir; ./processchk po" But Its getting error... (9 Replies)
Discussion started by: manohar2013
9 Replies
ORIGAMI(1)																ORIGAMI(1)

NAME
Origami - command-line management tool for Folding @ Home clients. SYNOPSIS
origami {install | archive | restore | erase | name | status | monitor | proxy | start | stop | version | help} [<options>...] origami {deploy | network-archive | network-restore | network-name | network-monitor | network-name | network-start | network-stop} [<options>...] origami help origami version DESCRIPTION
Origami allows you to install, monitor, archive or restore Folding @ Home data on your local machine. It also allows for central deployment, monitoring, archiving, restoration and updating the username and team data via the network to ssh-accessible machines. Origami supports cron-based scheduling, 32bit or 64bit and network proxy settings. Install Stanfords Folding @ Home client to a single machine or network of machines. COMMAND-LINE ACTIONS The first argument which does not begin with a hyphen ("-") is considered to be an action that the program should perform. If an action is not specified Origami will display the help output. The following actions are available to the local machine: install Install Folding @ Home to the local machine. This action will create a dedicated user, storage location for Folding @ Home data, startup script and request a work unit. deploy Install Folding @ Home to remote machines as listed in the ~/.origamirc file. This action will create a dedicated user, storage location for Folding @ Home data, startup script and request a work unit on the remote machine. SSH access as the root user is required for the deploy action. archive Archive Folding @ Home data for the local Folding @ Home client. This action will stop the Folding @ Home client, archive the current progress into a <hostname>-<date>.tar.bz2 format and store the data in ~/.origami/. network-archive Archive Folding @ Home data on the remote Folding @ Home client as listed in the ~/.origamirc. This action will stop the Folding @ Home client, archive the current progress into a <hostname>-<date>.tar.bz2 format and store the data in ~/.origami/. restore Restore Folding @ Home data on the local machine. This action will require previously archived data (as generated by the archive action). network-restore Restore Folding @ Home data on the remote Folding @ Home clients as listed in the ~/.origamirc. This action will require previously archived data (as generated by the network-archive action). erase Erase current Folding @ Home installation. Anything generated by the install function will be removed and all Folding @ Home progress will be lost. name Update the username and team information for the local Folding @ Home client. It is generally preferred to define username and team at installation with the install action. network-name Update the username and team information for the remote Folding @ Home clients. It is generally preferred to define username and team at installation with the deploy action. status|monitor Display the current progress of the local Folding @ Home client. network-status|network-monitor Disploy the current progress of the remote Folding @ Home clients as listed in the ~/.origamirc. proxy Update the proxy settings for the local Folding @ Home client. This action requires a port and hostname. It is generally preferred to define the proxy port and hostname at installation with the install action. start Start the local Folding @ Home client. (This calls /etc/init.d/origami start) network-start Start the remote Folding @ Home clients as listed in the ~/.origamirc. stop Stop the local Folding @ Home client. (This calls /etc/init.d/origami stop) network-stop Stop the remote Folding @ Home clients as listed in the ~/.origamirc. version Display the Origami version. help Display the Origami help output. OPTIONS
-u|--user=value Define the USERNAME that Folding @ Home data should credit. Default is Anonymous. -t|--team=value Define the TEAM NUMBER that Folding @ Home data should credit. Default is 0. -c|--cron=boolean Activate cron scheduling for the Folding @ Home client. Default is off (0). -p|--proc=value Define i386 or amd64 Folding @ Home client. Default is i386. -P|--port=value Define the port to be used in conjunction with a proxy. Default is 8080. -H|--host=value Define the IP or hostname to be used in conjunction with a proxy. Default is localhost. EXAMPLES
origami install This example will install the Folding @ Home client to the local machine, reporting data as the default Anonymous user and default 0 Team. origami install -u Joe -t 45104 This example will install the Folding @ Home client to the local machine, reporting data as the Joe user as part of the 45104 (TeamUbuntu) Team. origami deploy -u Joe -t 45104 This example will install the Folding @ Home client to all machines listed in the ~/.origamirc file, reporting data as the Joe user as part of the 45104 (TeamUbuntu) Team. origami install -u Joe -t 45104 -p amd64 -c1 This example will install the Folding @ home client to the local machine, reporting data as the Joe user as part of the 45104 (TeamUbuntu) Team, using the amd64 Folding @ Home client and toggling the cron option to auto-stop between the hours of 8:00am and 5:00pm. origami network-status This example will display the current status of the Folding @ Home clients on all machines listed in the ~/.origamirc file. BUGS
To find a list of current bugs, or to report a bug new bug please see https://bugs.launchpad.net/origami. AUTHORS
Origami was written by Christer Edwards <christer.edwards@ubuntu.com>. This manual page was written by Christer Edwards <christer.edwards@ubuntu.com>. Both are released under the GNU General Public License, version 2 or later. 2010-06-16 ORIGAMI(1)
All times are GMT -4. The time now is 04:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy