w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

How do I change the directory in Git Bash with Git for Windows?
You will need to use quotes in your directory name, or the short version of the filename. You can find the short version of the file name by issuing the command: dir /x If I remember correctly. I do not have a windows machine. It is a version of bash shell though, so you should be able to simply quote it. (And the dir /x may or may not work.)

Categories : Linux

making directory shortcuts like $HOME
HOME is a really bad choice, since many programs will use the value of HOME to find the home directory. However, you certainly can do #WARNING: this is a bad idea. It would be better to choose a #name other than "HOME" HOME="cd /p/a/t/h" $HOME Using a function would be more reliable and flexible, but it's certainly possible to put a command in a variable like this.

Categories : Osx

BASH | Adding elements in all files of a specific directory bash
This can make it: for file in /your/dir/* do echo "<end>" >> "$file" done In case you have some dirs inside, you may get the error bash: XX: Is a directory. To avoid seeing them, you can add 2>/dev/null to the end of the echo command: echo "<end>" >> "$file" 2>/dev/null Or even better (thanks Barmar), check if they are files: [ -f "$file" ] && echo "<end>" >> "$file" Which is a short way of doing an if-condition: if [ -f "$file" ]; then echo "<end>" >> "$file" fi

Categories : Bash

Bash script to analyze directory and print directory summary
in your code use the following : @where ls -ld is written getting directories ls -latr | sed -n '/^d/p' zdirlst | grep -v "." getting files : ls -latr | sed -n '/^-/p' zdirlst | grep -v "." add wc -l to get count and display as per reqd ... hope this helps !!

Categories : Bash

After I deleted a directory, it always prompts "shell-init error retrieving current directory getcwd solve" when log on bash
When opening a new shell or xterm, it's started in the working directory of the process that started it. If you e.g. cd /proc && xterm, the new terminal will place you in /proc. Whatever's starting your terminal had positioned itself in /home/desktop/zeno, and now all the terminals are trying to start there. If you make that process change directory (by rebooting, for example), the terminals will start in a directory that exists and you will no longer get this error.

Categories : Linux

Bash is symlinking to working directory instead of specified directory
Short answer Your quoting is wrong. ln -sn -- "$FILE_PATH" "$TEST_DIR/$FILE_NAME" Longer answer This does not really relate to your problem, but I want to point it out. Do not use "" inside [[ ]], so instead of this if [[ -z "$1" ]]; then use this if [[ -z $1 ]]; then What is the point of making sure that directory does not have a trailing slash? It has no effect! /usr/bin/ is the same directory as /usr/bin or /usr////bin or /usr////////bin////// Do not check if a directory exists when creating directories. Use -p option! Example: mkdir -p "$HOME/.config/old_dotfiles" Instead of if [ $DECISION == "N" -o $DECISION == "n" ]; use if [[ ${DECISION^^} == N]]; I have another great answer about bash code style HERE. Please check it out! Also read the comments, since I was explaining there

Categories : Linux

How to change the current working directory to a specific directory and execute a program under the specific directory?
One of your principal problems is that you don't capture the return value (output) of the command in backticks. You are merely throwing away the output you want. Do something like: my $output = `perl ./script.pl` system("perl ./script.pl")

Categories : Perl

How do I change symfony 2 doctrine mapper to use my custom directory instead of my Entity Directory under the bundle
you can tell Doctrine the directory where is your entities doctrine: orm: auto_generate_proxy_classes: %kernel.debug% auto_mapping: false mappings: name: type: php dir: %kernel.root_dir%/../src/Company/CartoDBBundle/Tests/CartoDB/Entity Here you have the full documentation Doctrine configuration I made a similar question a few days ago, there you can read the full answer Cedar gave me Similar post

Categories : PHP

For a Ruby CLI, what is the most reliable way to change directory to users root/home directory?
To summarize Avdi Grimm's screencast on the same subject, If you're using a Ruby version greater than 1.9, the Dir module provides a method #home. However, this depends on the environment variable HOME set on the user's shell session. To reliably get the home dir, you should pass in the login name of the current user to the Dir.home command. Or, in code: # Works if HOME is set in the environment i.e., if "echo $HOME" returns the home directory # when that command is run on the command-line Dir.home # => /Users/<username>, Works if HOME is set # If the HOME environment variable is not set, you should explicitly pass in the username # of the currently logged-in user Dir.home(username) # => /Users/<username> # The current username can be obtained using username

Categories : Ruby

Bash No such file or directory
Remove the extra $ before diffv assignment. Use: diffv=$(which diff) And: diffv=$MY_DIFF With $ you get: <diffv value, empty>=<MY_DIFF value, or which diff> =/opt/gnu/bin/diff

Categories : Bash

bash: is possible to prefix a command with a directory?
Using the auxiliary shell variable is not that ugly, and would be fine to use. Another option is to write a simple wrapper that will search the PATH for you. For example, call this script path: #!/bin/bash IFS=: for i in $PATH; do cmd="$i/${1?No command specified}" if test -x $cmd; then shift IFS=$' ' exec "$cmd" "$@" fi done echo Command not found: "$1" >&2 exit 1 and invoke it from the crontab as: path foomatic/featurizer

Categories : Bash

BASH if directory contains files or doesn't
find could be helpful here: if [[ $(find ${dir} -type f | wc -l) -gt 0 ]]; then echo "ok"; fi UPD: what is -gt? man bash -> / -gt/: arg1 OP arg2 OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These arithmetic binary operators return true if arg1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to arg2, respectively. Arg1 and arg2 may be positive or negative integers. So, -gt is "greater than" boolean function.

Categories : Bash

How do I get the absolute directory of a file in bash?
To get the full path use: readlink -f relative/path/to/file To get the directory of a file: dirname relative/path/to/file You can also combine the two: dirname $(readlink -f relative/path/to/file) If readlink -f is not available on your system you can use this: function myreadlink() { ( cd $(dirname $1) # or cd ${1%/*} echo $PWD/$(basename $1) # or echo $PWD/${1##*/} ) } Note that if you only need to move to a directory of a file specified as a relative path, you don't need to know the absolute path, a relative path is perfectly legal, so just use: cd $(dirname relative/path/to/file) if you wish to go back (while the script is running) to the original path, use pushd instead of cd, and popd when you are done.

Categories : Linux

Run bash script as if I it was executed from a different directory
you could change the working directory before you execute each script, or redirect the output to the directory you want: cd /experiments/exp1/ sh /experiments/exp1/script1.sh >report1.txt or sh /experiments/exp1/script1.sh > /experiments/exp1/report1.txt

Categories : Linux

Bash - Printing Directory Files
Here is a solution: #!/bin/bash target="/home/personal/scripts/07_22_13/ford/$1" let count=0 for f in "$target"/* do echo $(basename $f) let count=count+1 done echo "" echo "Count: $count" Solution 2 If you don't want to deal with parsing the path to get just the file names, another solution is to cd into the directory in question, do your business, and cd back to where you were: #!/bin/bash target="/home/personal/scripts/07_22_13/ford/$1" pushd "$target" > /dev/null let count=0 for f in * do echo $f let count=count+1 done popd echo "" echo "Count: $count" The pushd and popd commands will switch to a directory, then return.

Categories : Linux

bash:python3.3 no such file or directory
It seems like bash is caching the previous location of python3.3 somewhere. Try closing your shell and logging in once again - that should wipe the cache and allow bash to pick up the proper location of python3.3.

Categories : Linux

bash script gives directory listing as well when tokenizing
The most likely issue that I can think of that could produce this would be that there is a * in $line, and the shell is expanding that (globbing). You can disable globbing with set -f. Try: set -f # disable globbing for word in $line do inner_count=$((inner_count + 1)) echo "$word" done set +f # re-enable globbing

Categories : Bash

Bash - How can I locate a specific file in a directory within a loop?
try export d="`pwd`" find ./A/*|while read file do echo "$file" if [ -f "$d/B/${file}_extendedname1.jpeg" ] then echo "$d/B/${file}_extendedname1.jpeg" found fi done

Categories : Bash

monitor a directory and pull new files as they appear - bash script
Two products come to mind depending on how you plan to approach the solution. I personally use Splunk on a variety of platforms (Windows & Linux servers/local Linux & OSX dev environments). It is a real-time log aggregator that features an API and the ability to query. Even if this doesn't solve your problem, the free version has some very robust features that you should consider: http://www.splunk.com The second approach would be synchronization of your web directories using something like RSync. I've used RSync on Linux boxes and always appreciated what it can do. I even see it now has a Windows port: https://www.itefix.no/i2/cwrsync

Categories : Bash

directory is not creating while running bash shell script in php
Check with which user's permissions it's run. You could echo the output of "whoami" (bash) command to know with wich user is used to run the script. If it's executed, for example, with the "www-data" user (ubuntu's [and maybe others] default httpd user), then it may not have the rights to create a directory in your user's home folder.

Categories : PHP

Regarding changing bash file and making new directory for mongodb
Can you add it to your bashrc? cd nano .bashrc mongodb="path_To_mongodb.exe" ## add this to bashrc, save and quit. Then restart terminal. Make sure there no spaces. Replace "path_To_mongodb.exe" with the actual path to your exe. Make sure it's in the right file, and saved, and terminal restarted, and if you're trying it in a script, expand the variables by adding shopt -s expand_aliases source ~/.bashrc to the start of the script.

Categories : Osx

"env: bash: No such file or directory" trying to run gradle on Jenkins on Mac Mini
Glenn essentially answered my question above in his comment. My PATH in Jenkins was different from my PATH from the terminal. I went and updated my /etc/launchd.conf file and added /bin to the PATH and Jenkins was able to find bash.

Categories : Android

Bash - replace string inside all files in directory
I would do this using sed like so: sed -i "/^[ ]*ODI_SESJA_ID CONSTANT/s/'[^']+'/'REPLACEMENT'/" *.ctl The -i flag to sed means it modifies the files in place, so I usually try it on a single file first with the -e flag instead of the -i flag and confirm that sed's output is what I was looking for. Explanation: The double-quotes protect my regex from the shell. /^[ ]*ODI_SESJA_ID CONSTANT/ matches only the lines that start with whitespace followed by 'ODI_SESJA_ID CONSTANT'. s/'[^']+'/'REPLACEMENT'/ substitutes 'REPLACEMENT' (quoted) for the first quoted portion of the text on matching lines. The document at http://www.catonmat.net/blog/wp-content/uploads/2008/09/sed1line.txt (top Google hit for 'sed one liners' is pretty helpful for quickly dispatching these sort of tasks.

Categories : Bash

How to solve "bash: script/extension: No such file or directory"
It's because this plugin is for old version of spree which was for Rails 2.x and this command syntax is deprecated by now. I think it would be better for you to use something more up-to-date, like https://github.com/nebulab/spree-subscriptions.

Categories : Ruby On Rails

bash: find all files in a directory and use part of the name as argument for a command
Try: find . -name "*.jpg" -exec sh -c 'mycommand -in $0 -out "${0%.*}.tif" --otherparam paramvalue' {} ; This will pass command of the form mycommand -in <imagebasename>.jpg -out <imagebasename>.tif --otherparam paramvalue to -exec. EDIT: For removing leading ./, you could say: find . -name "*.jpg" -exec bash -c 'f={}; f=${f/.//}; echo mycommand -in "${f}" -out "${f%.*}.tif" --otherparam paramvalue' {} ; (Note that the interpreter for -exec has changed.)

Categories : Bash

bash: etc/postgresql/8.4/main/pg_hba.conf: No such file or directory
PostgreSQL doesn't start without this file - so pg_hba.conf should exist on your server. This file is usually in data directory - you can try sudo su postgres psql postgres -c "show hba_file"

Categories : Postgresql

Allowing punctuation characters in directory and file names in bash
Always quote your variable substitutions. I.e. not cp $source $target, but cp "$source" "$target". This way they won't be subject to word splitting and pathname expansion. Specify "--" before positional arguments to file operation commands. I.e. not cp "$source" "$target", but cp -- "$source" "$target". This prevents interpreting file names starting with dash as options. And yes, "/" is not a valid character for file/directory names.

Categories : Bash

How to call a bash script automatically when directory contents chage
Linux provides a nice mechanism for that purpose which is called inotify. inotify is mostly available as a C API. But there have been developed shell utilities as well. You should use inotifywait from inotifytools (pkg name in debian) for this. Here comes a basic example: #!/bin/bash directory="/tmp" # or whatever you are interested in inotifywait -m -e create "$directory" | while read folder eventlist eventfile do echo "the following events happened in folder $folder:" echo "$eventlist $eventfile" done Update: If the problem goes complicated, for example you'll have to monitor recursive, dynamic directory structures, you should have a look at incron It's a cron like daemon which executes scripts on certain events. But the events are file system events rather than timer eve

Categories : Linux

Recursively rename directory in reverse order, Bash script
You seem to be trying to use find -exec syntax without actually using find. Use find with its -depth option to make it return directories from deepest to closest. find . -depth -type d ! -name '.' -exec sh -c 'mv "$0" "$0.$(date "+%H%M%S%N")"' {} ;

Categories : Bash

New tab in Terminal.app does not open in same directory/bash fails (Mountain Lion)
I had this problem too, and discovered that I had accidentally changed a setting in the "Startup" tab of the Terminal preferences. The setting was "Shells open with: Command (complete path): ." I changed it back to "Shells open with: Default login shell" and that solved the problem.

Categories : Bash

Running a subprocess bash script from Python in the scripts current directory
Yep, Just before your loop programitically save the current working directory and change the current working directory to /some%s before the subprocess.call and then set it back to the original value when you are done. import os Orig = os.path.abspath('.') for i in range(1,100): os.chdir('/some%s' % i) subprocess.call(['./task.sh' % i, arg1]) os.chdir(Orig)

Categories : Python

Linux Bash Shell Script: How to "ls" a directory and check some output string?
To check for a directory: if [ ! -d '/var/aaaaaaa' ]; then echo 'no dir!' fi For file: if [ ! -f '/var/aaaaaaa' ]; then echo 'no file!' fi To check output: if ls '/var/aaaaaaa' 2>&1 | grep 'No such'; then echo 'no such'; fi To check when ls fails: if ! ls '/var/aaaaaaa' &> /dev/null; then echo 'failed' fi

Categories : Linux

How to change shell to dash from bash
SHELL environment variable picks up the value from /etc/passwd. (It denotes the path to user's preferred command language interpreter.) This value wouldn't change if you change the shell in your session or your script.

Categories : Bash

Bash script that move files from one directory with lots of files to a month folder
something like this? DEBUG=echo cd ${directory_with_files} for file in * ; do dest=$(stat -c %y "$file" | head -c 7) mkdir -p $dest ${DEBUG} mv -v "$file" $dest/$(echo "$file" | sed -e 's/.* (.*)/1/') done DISCLAIMER: test this in a safe copy of your files. I won't be responsible for any lost of data ;-)

Categories : Bash

how to create a script from a perl script which will use bash features to copy a directory structure
First, I see that you want to make a copy-script - because if you only need to copy files, you can use: system("cp -r /sourcepath /targetpath"); Second, if you need to copy subfolders, you can use -r switch, can't you?

Categories : Perl

rails heroku - error code H10 bash: bin/rails: No such file or directory
Rails 4 project had a /bin directory, unlike some older Rails 3 projects I had cloned. /bin contains 3 files, bundle, rails, and rake, but these weren't making it to Heroku because I had bin in my global .gitignore file. This is a pretty common ignore rule if you work with Git and other languages (Java, etc.), so to fix this: Remove bin from ~/.gitignore Run bundle install Commit your changes with git add . and git commit -m "Add bin back" Push your changes to Heroku with git push heroku master

Categories : Ruby On Rails

Command works in command line but gives 'no such file or directory' in bash script
Remove the quotes around line 8. Like this: ./optAlg.exe "$inputFile" 500 2>&1 > "output/$outputFile" By placing quotes around the whole line you tell bash to execute a command which is called exactly ./optAlg.exe $inputFile 500 2>&1 > output/$outputFile and of course there is no such command. In reality you want to run ./optAlg.exe with parameters. Do not forget to place quotes around the variables because otherwise filenames that have whitespace characters are going to be passed as several arguments. Please read about arguments. And you can read about common pitfalls as well.

Categories : Bash

How to modify bash command to change permissions
You can try this: find . -type d (-name "*" ! -name "A" ! -name "B" ) -exec chmod 755 {}; find . -type d (-name "*" - lists all the directories in the current directories !-name "A" !-name "B" - ignores directories with names A and B

Categories : Linux

How to change the result when file does not exist in bash?
The best error handling in this case is to check whether the file exist and if so, do the cat, not the other way round. Like this: file="/ieee80211/phy2/rcstats" if [ -f $file ] then v1=$(< $file) fi

Categories : Bash



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.