Alias not running on sunos server - alias

I am trying to create alias in sunos server but no luck i am putting my code of ~/.bashrc file !! (its code of my bashrc file )
alias le=`cd /Products/Logs`
If [ -f /etc/bashrc ]; then
./etc/bashrc
fi

Seems like you set wrong quotation marks. The first line must be:
alias le='cd /Products/Logs'
(with single quotes)
And this line:
./etc/bashrc
should be
. /etc/bashrc
And do not forget to logout then login. Or exec . ~/.barshrc

Related

Errors ("invalid command") when opening a .sql file

I am trying to open a random .sql file off the internet using the following command:
psql -h localhost -d database_name -U postgres < file_name.sql
But when I run this command I just get errors like the following:
invalid command 's
invalid command 's
invalid command 'll
invalid command 'Moving
invalid command 's
invalid command "frequently
It just continuously prints out these invalid command error messages. I thought it might be an encoding problem but I confirmed the file is UTF-8 encoded.
Any suggestions on how I can open this file
To expand and clarify on a_horse_with_no_name's comment - the psql command you are running should be run directly in your shell, not inside pgadmin4.
youruser#yourmachine:~$ psql -h localhost -d database_name -U postgres < file_name.sql
That command should load the contents of file_name.sql in to database_name. Once it's complete, you can use pgadmin4 as normal to interact with the database.
One possibility is that the file contains tabulator keys, which are expanded if you read redirect standard input to the SQL script.
Try using the -f option:
psql -h localhost -d database_name -U postgres -f file_name.sql
Apparently the .sql file was generated through a MySQL dump. I thought it would not matter whether I used PostgreSQL or MySQL but it did. Once I installed MySQL my problem got resolved and I now have a Database ready :)

SCP command to copy more than one file from remote to remote server?

I use this command single line to copy a folder named 'myFolder1' from remote server to remote server. It works fine.
I run this command in the 'terminal' of 'myserver2'. This is the destination server, I mean the server the folder will be copied to.
scp -r myserver#190.93.133.6:/home/myserver/www/wp-content/plugins/myFolder1 .
If I need to copy two folders (instead of one)I need to run my command two times (one for each folder) like this:
scp -r myserver#190.93.133.6:/home/myserver/www/wp-content/plugins/myFolder1 .
scp -r myserver#190.93.133.6:/home/myserver/www/wp-content/plugins/myFolder2 .
My question: is there a way to join these two commands into a single command line?
Yes, there is. Just use the wildcard character * and the quotes ".
Here an example:
scp -r "myserver#190.93.133.6:/home/myserver/www/wp-content/plugins/myFolder*" .
But you can also be more precise using other wildcard characters:
scp -r "myserver#190.93.133.6:/home/myserver/www/wp-content/plugins/myFolder{1,2}" .
💡 Note the quotes used to wrap the path and the wildcard.
The simplest solution is:
scp -r myserver#190.93.133.6:/home/myserver/www/wp-content/plugins/myFolder{1,2} .
An asterick definitely works here, but it matches more than 1 and 2 thus may cause unwanted result. Note that {a,b,c,d} only works on remote path. So if you want to copy from local to remote server, use this instead:
scp -r myFolder1 myFolder2 user#host:/path/

bash sqlplus command not found

I am trying to install sqlplus on my mac following the tutorial here: https://tomeuwork.wordpress.com/2014/05/12/how-to-install-oracle-sqlplus-and-oracle-client-in-mac-os/comment-page-1/#comment-6
I have downloaded the two packages (basic and sqlplus) and created all the directories as it says, I moved the necessary files inside the directories.
I created and copied the tnsnames.ora file with the contents:
MYDB=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=*********)
(PORT=1521)
)
(CONNECT_DATA=
(SERVER=dedicated)
(SID=MYDB-SID)
) )
And i created the .bash_profile as it says in the tutorial.
But what im stuck on is making the sqlplus run.
typing in sqlplus returns command not found.
in the tutorial it says i should use $ sqlplus username/password#database
where do i get the username and database name from?, I haven't created one yet.
Thanks in advance.
According to your article, you should do the following:
$ vi ~/.bash_profile
Add the following line to the end of the file.
alias sqlplus=’rlwrap sqlplus’
Now reload the .bash_profile:
$ source ~/.bash_profile
Looks like you missed these steps.
You can try to execute:
$rlwrap sqlplus
According to the comments below you do not have sqlplus in the $PATH.
The value of $PATH looks wrong to me: duplicates, quotes.
Option 1
Execute:
export PATH=/Applications/‌​or‌​acle/product/instantclient_64/11.2.0.4.0/bin:/usr/local/bin:/usr/bin:/bin:/us‌​r/s‌​bin:/sbin
Then execute in the same console:
$ sqlplus (or $ rlwrap sqlplus)
It will set value only for the current shell. The main idea is to have full path to the sqlplus binary in the $PATH.
Option 2
Modify ~/.bash_profile.
To save as a permanent environment variable edit ~/.bash_profile. There are some details about setting PATH in the source article.
Top down troubleshooting approach
Look for binary - use type
[bbrandt] ~/ $ type sqlplus
sqlplus is aliased to `rlwrap sqlplus'
Where is my binary.. hidden behind an alias, let's unalias
[bbrandt] ~/ $ unalias sqlplus
[bbrandt] ~/ $ type sqlplus
sqlplus is /u01/app/oracle/product/11.2.0/xe/bin/sqlplus
Found it! What happens if I modify my binary search-path?
[bbrandt] ~/ $ echo $PATH
/u01/app/oracle/product/11.2.0/xe/bin:/home/bbrandt/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
[bbrandt] ~/ $ export PATH=/home/bbrandt/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
Now, where is my binary?
[bbrandt] ~/ $ type sqlplus
bash: type: sqlplus: not found
[bbrandt] ~/ $
This is where you are... look in your $PATH variable

Open up a sql file and running it in PostgreSQL is having an issue with the path because of space in the folder name

I'm using command line to run the following script:
C:\Progra~1\pgAdmin III\1.16\psql -d [tablename] -h [servername] -p 5432 -U postgres -f C:\test\query.sql
But the issue comes with the folder pgAdmin III that I want to run the query in since it has a space in the name. When I changed the actual folder name to pgAdminIII and updated the script it will run the script just fine. I was wondering how I can run this script without physically modifying the folder name (i.e. keep it as pgAdmin III)?
Put double qoutes around a path with spaces in it:
"C:\Progra~1\pgAdmin III\1.16\psql" -d [tablename] ...

May I define aliases elsewhere than into .bashrc?

We are several persons using the same login id on Linux Box.
I want to define my own aliases without interfering with anyone.
In the .bashrc, I define a alias to my bash file defining my own aliases.
alias luc=/full/path/to/my/def_alias_luc.sh
The file /full/path/to/my/def_alias_luc.sh contains
#!/bin/bash
echo ""
echo "Defining Luc's aliases"
echo ""
echo ""
echo "aliases before..."
echo ""
alias
alias vimluc="vim -u /full/path/to/my/.vimrc "
echo ""
echo "aliases after"
echo ""
alias
After executing /full/path/to/my/def_alias_luc.sh, the alias is still undefined.
What do I miss ?
Don't you want to source that file (i.e. run it within the existing bash process) rather than spawn off a new bash process (as the first line of the script would suggest you're doing) ?