Probably a repetitive question, but need some to-the-point answers as I'm still learning. I have a script and need to update the application the script is pulling how do I go about such a thing ?
I do not know where to start I am just getting back into scripting.
I love using aliases on my ubuntu server for repeated commands as they're a huge timesaver and they're absolutely irreplaceable for me now.
I've been using cmder a lot recently on Windows as it is the best console replacement for windows that I know of. It is a wonderful piece of software and I have almost all the basic bash commands including aliases.
However, I cannot find a way to chain multiple alias commands. I've tried delving into doskey at this link Microsoft DOSKEY and the macros without any luck.
So, basically I want to create multiple aliases. For e.g.
alias loginuser1='ssh -i ~/user1keyfile user1#$s'
alias mynewcloudserver='901.801.701.601'
and want to be able to login by typing:
loginuser1 mynewcloudserver
loginuser5 mytestingcloudserver
I have currently tried this:
loginuser1 mynewcloudserver
which produces this error:
ssh: Could not resolve hostname mynewcloudserver: no address associated with name
I get that this is because it is probably looking in my hosts file for mynewcloudserver and is unable to find an entry. I am able to login by doing this instead:
loginuser1 901.801.701.601
which brings us to my problem. I am unable to call one alias from another alias
I know the above might not be the best way to create those aliases, but I just want to understand the logic and how to chain aliases together in cmder which will open up a host of possibilities pun intended.
If anyone can help me out, that would be great.
The only option I've found is to create a myscript.sh file with the commands, and create an alias to call the file.
It may be helpful to include wait between commands if they need to finish before the next one runs.
The first time you run it, it may ask you which program to use. Choose Git for Windows.
I'm not a PL/SQL developer but my current task at work needs me to go through a lot of them. I'm trying to learn it quick but oracle documentation seems tedious. So asking this question.
In one of the .sql script I seen,
installer.sql
##pkgstringinteger.h
##pkgstringinteger.sql
##load_policy.sql
so what does this ## do?
I know on sqlplus prompt if we have to execute any .sql file then we put # at the start. e.g.
SQL>#load_policy.sql
But was wondering what would putting it twice would do? I tried to google but it was difficult to get answer to this peculiar question.
Thanks
##foo.sql does the same thing as #foo.sql (executes the commands in that file), but looks for the file in the same directory as the calling file.
I have a script and within that script I am calling several other scripts.
Now I have a requirement where I need to get the list of all the scripts that have been run as I need to audit these in the database.
I have tried the history command but it does not seem to be working.
Can anyone propose any approaches that would help me.
Thank you!
I want to execute my bash scripts normally but no body see my source codes.
How can i encrypt my bash script?
thanks a lot.
Bash is a pure interpreted language so the interpreter (bash) can only run it if it is clear text.
You can try to obfuscate the code:
How to minify/obfuscate a bash script
On the other hand, you can restrict which users access to that code using system privileges.
Sorry to wake up a "dead horse", just wanted to share what I have done using gpg. As mentioned earlier bash can only run it (the script) if it is in clear text.
encrypt the shell script with gpg:
gpg -c <your_bash_script.sh>
This will ask you for a passphrase and confirm it.
This will create an encrypted file with a .gpg extension. the default encryption is CAST5 if you want a more strict cipher add --cipher-algo "cipher_name" (check the man pages for details)
<your_bash_script.sh.gpg>
decrypt your shell script with gpg:
gpg -d <your_bash_script.sh.gpg>
This will prompt you for the passphrase assigned to the file and display its contents in the on the screen.
if you put it all together, you have:
gpg -d <your_bash_script.sh.gpg> | bash
You can even use gpg keys
Every time you edit your script, you edit the un-encrypted version of the script or pipe the output of the decryption to a file and re-encrypt it when done.
You could use shc. Here is an example. Not really sure if this is a great place to ask this question though. Doesn't seem super programming-related. Super User might be a better place for it. :)
http://www.thegeekstuff.com/2012/05/encrypt-bash-shell-script/
Other answers and comments have already said that encryption isn't feasible so I won't go into that. I don't think that path even addresses the problem you are trying to solve.
You haven't given a practical example of what you are trying to achieve, so the suggestions below may not be sufficient.
With almost any problem it's best to start of with the simplest approach first and add complexity as needed. First of all, you may not need to do anything at all! When you execute a shell script, the process list will only show the name of the shell executing the script (bash) and the name of the script. No-one will be able to see the contents of the script this way.
If that doesn't meet your needs then the next step would be to use standard file permissions to ensure that no-one can look at the contents of the file. ie. Remove read/write/execute permissions for group and other
chmod go-rwx <name of script>
If neither of these are enough, you will have to provide more details about what you are trying to do and what your concerns are.
I recommend you try submitting your script to this site if you wish to protect it from public view.
While many will disagree with the idea of hiding the source code of a script written in an interpreted language, i understand why there's a desire for this work.
As someone who has had his work stolen many times, I just dont care if "obfuscation" or "encryption" is a taboo. As long as my script is protected and it works as it did before encryption, I'm happy. Never again will I allow someone else to take credit for my work. And no, writing my script in a compiled language is not an option. I do not know how to.
Anyway, if you do not want to use the site mentioned above, try the latest version of shc. I believe they've updated it in github to address the many security concerns others have mentioned. Type the following into google "shc github" and you'll see a host of available options you can try out.