0

I'd like to use some commands on my Orange pi zero within reach, for example: I want to execute one command on ubuntu, and I want to have every commands on 1 file.

my_file (without ending in .sh)

#!/bin/bash
alias myip='curl ipinfo.io/ip'
alias tururu='echo it works'

Have this file, and chmod -x was executed on this file, but when I do on terminal "sh my_file myip", doesn't do anything, but didn't give me an error, so what I'm doing wrong?

Thank you very much

1
  • I think you mean to: source my_file && myip Commented Dec 5, 2017 at 15:29

1 Answer 1

3

sh myfile myip is one command; it doesn't run sh myfile, then myip. Your script should just look like

#!/bin/sh
curl ipinfo.io/ip
echo it works

then run as sh myfile (or myfile, assuming it is executable and located in a directory on your path).

If, instead, you want to execute myfile so that you can subsequently use myip and tururu as commands, you need to source the file:

$ source myfile
$ myip
192.0.2.24
$ tururu
it works
Sign up to request clarification or add additional context in comments.

1 Comment

Wow! Thanks you so much! You save me from the suicide! Jeje

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.