Reputation: 1328
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
Upvotes: 0
Views: 66
Reputation: 530960
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
Upvotes: 3