I have been trying to source this script from Xilinx install but it outputs an error.
source /opt/Xilinx/14.7/ISE_DS/settings32.csh
# Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
set SETTINGS_FILE=.settings32.csh
set XIL_SCRIPT_LOC="/opt/Xilinx/14.7/ISE_DS"
if ( $# != 0 ) then
# The first argument is the location of Xilinx Installation.
# Don't detect the installation location.
set XIL_SCRIPT_LOC="$1"
else
# XIL_SCRIPT_LOC should point to script location
set XIL_SCRIPT_LOC_TMP_UNI=`echo $_ | cut -d" " -f 2`
set XIL_SCRIPT_LOC_TMP_UNI_TAIL=${XIL_SCRIPT_LOC_TMP_UNI:t}
set XIL_SCRIPT_LOC_TMP_UNI=${XIL_SCRIPT_LOC_TMP_UNI:h}
if ( "$XIL_SCRIPT_LOC_TMP_UNI" != "" ) then
if ( "$XIL_SCRIPT_LOC_TMP_UNI" == "$XIL_SCRIPT_LOC_TMP_UNI_TAIL" ) then
set XIL_SCRIPT_LOC_TMP_UNI="./"
endif
set XIL_SCRIPT_LOC_TMP_UNI=`readlink -f ${XIL_SCRIPT_LOC_TMP_UNI}`
if ( $? == 0 ) then
set XIL_SCRIPT_LOC=${XIL_SCRIPT_LOC_TMP_UNI}
endif
endif
unset XIL_SCRIPT_LOC_TMP_UNI_TAIL
unset XIL_SCRIPT_LOC_TMP_UNI
endif
set xlnxInstLocList=""
set xlnxInstLocList="${xlnxInstLocList} common"
set xlnxInstLocList="${xlnxInstLocList} EDK"
set xlnxInstLocList="${xlnxInstLocList} PlanAhead"
set xlnxInstLocList="${xlnxInstLocList} ISE"
set XIL_SCRIPT_LOC_TMP_UNI=${XIL_SCRIPT_LOC}
foreach i $( xlnxInstLocList )
set d="${XIL_SCRIPT_LOC_TMP_UNI}/$i"
set sfn="$d/$SETTINGS_FILE"
if ( -e "$sfn" ) then
echo source "$sfn" "$d"
source "$sfn" "$d"
endif
end
bash: /opt/Xilinx/14.7/ISE_DS/settings32.csh: line 42: syntax error:
unexpected end of file
Can someone see the error in the script?
Related
If I'm in a deep directory, let's say
/run/media/PhoenixFlame101/Coding/Projects/react-app
the fish prompt currently looks like this:
/r/m/Ph/C/P/react-app >
How do I change it to show only the current directory? Like this:
react-app >
I am also using tide, if that makes any difference.
Edit:
Since #glenn-jackman asked here's the outputs of type fish_prompt:
fish_prompt is a function with definition
# Defined in /home/PhoenixFlame101/.config/fish/functions/fish_prompt.fish # line 2
function fish_prompt
_tide_status=$status _tide_pipestatus=$pipestatus if not set -e _tide_repaint
jobs -q && set -lx _tide_jobs
/usr/bin/fish -c "set _tide_pipestatus $_tide_pipestatus
set _tide_parent_dirs $_tide_parent_dirs
PATH=$(string escape "$PATH") CMD_DURATION=$CMD_DURATION fish_bind_mode=$fish_bind_mode set _tide_prompt_4007 (_tide_2_line_prompt)" &
builtin disown
command kill $_tide_last_pid 2>/dev/null
set -g _tide_last_pid $last_pid
end
math $COLUMNS-(string length -V "$_tide_prompt_4007[1]$_tide_prompt_4007[3]")+5 | read -lx dist_btwn_sides
echo -ns \n''(string replace #PWD# (_tide_pwd) "$_tide_prompt_4007[1]")''
string repeat -Nm(math max 0, $dist_btwn_sides-$_tide_pwd_len) ' '
echo -ns "$_tide_prompt_4007[3]"\n"$_tide_prompt_4007[2] "
end
and type prompt_pwd:
prompt_pwd is a function with definition
# Defined in /usr/share/fish/functions/prompt_pwd.fish # line 1
function prompt_pwd --description 'short CWD for the prompt'
set -l options h/help d/dir-length= D/full-length-dirs=
argparse -n prompt_pwd $options -- $argv
or return
if set -q _flag_help
__fish_print_help prompt_pwd
return 0
end
set -q argv[1]
or set argv $PWD
set -ql _flag_d
and set -l fish_prompt_pwd_dir_length $_flag_d
set -q fish_prompt_pwd_dir_length
or set -l fish_prompt_pwd_dir_length 1
set -l fulldirs 0
set -ql _flag_D
and set fish_prompt_pwd_full_dirs $_flag_D
set -q fish_prompt_pwd_full_dirs
or set -l fish_prompt_pwd_full_dirs 1
for path in $argv
# Replace $HOME with "~"
set -l realhome ~
set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $path)
if test "$fish_prompt_pwd_dir_length" -eq 0
echo $tmp
else
# Shorten to at most $fish_prompt_pwd_dir_length characters per directory
# with full-length-dirs components left at full length.
set -l full
if test $fish_prompt_pwd_full_dirs -gt 0
set -l all (string split -m (math $fish_prompt_pwd_full_dirs - 1) -r / $tmp)
set tmp $all[1]
set full $all[2..]
else if test $fish_prompt_pwd_full_dirs -eq 0
# 0 means not even the last component is kept
string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*' '$1' $tmp
continue
end
string join / (string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp) $full
end
end
end
I'm not sure what exactly this does, but I hope it helps!
I am new to Batch scripting.
I am trying to write a script which parses given command and check if argument with name 'folder 'is present in that command and if not , add that argument with default value.
I have written following script. This scripts executes correctly if argument is missing.
But if argument is present , both if and else blocks are executed.
Please help. Thanks in advance.
#echo off
set ARGS=-action generate -folder "Source"
set t=%ARGS%
echo %t%|find "-folder" >nul
if errorlevel 1 (
goto setDefaultFolder
) else (
echo Folder is specified in command
)
:setDefaultFolder
echo Folder is NOT specified in command. User's current directory will be used as Folder.
set folderArgName=-folder
set folderArgValue="%cd%"
set folderArg=%folderArgName% %folderArgValue%
echo folderArgName : %folderArgName%
echo folderArgValue : %folderArgValue%
echo folderArg: %folderArg%
set ARGS=%ARGS% %folderArg%
echo ARGS : %ARGS%
Output of code :
Folder is specified in command
Folder is NOT specified in command. User's current directory will be used as Folder.
folderArgName : -folder
folderArgValue : "C:\work"
folderArg: -folder "C:\work"
ARGS : -action generate -folder "Source" -folder "C:\work"
You have to have a goto in the else, that goes to after the setDeafultFolder, otherwise it just will execute the setDefaultFolder after it
#echo off
set ARGS=-action generate -folder "Source"
set t=%ARGS%
echo %t%|find "-folder" >nul
if errorlevel 1 (
goto setDefaultFolder
) else (
echo Folder is specified in command
goto endOfBatch
)
:setDefaultFolder
echo Folder is NOT specified in command. User's current directory will be used as Folder.
set folderArgName=-folder
set folderArgValue="%cd%"
set folderArg=%folderArgName% %folderArgValue%
echo folderArgName : %folderArgName%
echo folderArgValue : %folderArgValue%
echo folderArg: %folderArg%
set ARGS=%ARGS% %folderArg%
echo ARGS : %ARGS%
:endOfBatch
I'm writing a script and have a problem when trying to get a date from the table. I'm having problem storing it into a variable. I always get the error:
Badly placed ()'s.
The variable TIMEFRAME is "D" and the shell actually gets into the IF, also the password is also not the problem as I use it to connect manually and check the query (no problems here).
This is the part of the script where I'm having problems.
#!/bin/csh -f
if ( $TIMEFRAME == "D" ) then
set TIMEBEG = `sqlplus -s $PASSWORD << EOF \
set head off; \
set feed off; \
select to_char(trunc(sysdate) - 1,'YYYYMMDD') from dual; \
exit; \
EOF`
set TIMEEND = $TIMEBEG"235959"
set TIMEBEG = $TIMEBEG"000000"
endif
I also tried to store it on a file, same problem
#!/bin/csh -f
set tmp_file=/tmp/tmp.$$
if ( $TIMEFRAME == "D" ) then
sqlplus -s $PASSWORD > $tmp_file << EOF \
set head off \
set feed off \
select to_char(trunc(sysdate) - 1,'YYYYMMDD') from dual; \
exit; \
EOF
set TIMEBEG=`cat $tmp_file`
set TIMEEND = $TIMEBEG"235959"
set TIMEBEG = $TIMEBEG"000000"
endif
I tried different solutions but with the same problem, tried without semi-colons, without the SETs, to put it on a single line, I'm out of Ideas.
When trying with -xvf this is what I get when I get into the part:
if ( $TIMEFRAME == "D" ) then
if ( D == D ) then
sqlplus -s $PASSWORD > $tmp_file << EOF set head off set feed off select to_char ( trunc ( sysdate ) - 1,'YYYYMMDD' ) from dual ; exit ; EOF
Badly placed ()'s.
Any ideas? This is running on Amazon Linux
I'm not sure you can use a here-doc inside backticks in C shell.
Write the sqlplus input to a file, rather than writing the whole sqlplus command.
#!/bin/csh -f
set tmp_file=/tmp/tmp.$$
if ( $TIMEFRAME == "D" ) then
cat > $tmp_file <<EOF
set head off
set feed off
select to_char(trunc(sysdate) - 1, 'YYYYMMDD') from dual;
exit;
EOF
set TIMEBEG = `sqlplus -s $PASSWORD < $tmp_file`
set TIMEEND = $TIMEBEG"235959"
set TIMEBEG = $TIMEBEG"000000"
endif
I know how to set commandline parameters for shortcuts to cmd files, by modifying a target-shortcut property.
"C:\test\cT.cmd" -logpk cur -lp c:\xxx\testlogs
But how can i feed more than one argument values to an argument point
C:\test\cT.cmd -logpk cur -lp c:\xxx\testlogs -s 22.07.2014 14:30:00
The thing above works as cmd command but if i add it to a shortcut target the "-s" option is not filled by the cmd properly.
"C:\test\cT.cmd" -logpk cur -lp c:\xxx\testlogs -s 22.07.2014 14:30:00
Maybe you know how to split "morenode arguments" so they can be used for shortcuts too.
best regards
EDIT:
if "%argument%" == "-s" (
set startDay=%argumentValueOne%
set startTime=%argumentValueTwo%
if "%argumentValueOne%" == "a" set startDay=""
if "%argumentValueTwo%" == "A" set startTime=""
set startDate=-s %startDay% %startTime%
echo startDate %startDate%
shift
shift
shift
goto validate
)
EDIT2:
C:\test\>
if "-s" == "-s" (
set startDay=22.07.2014
set startTime=14:30:00
if "22.07.2014" == "a" set startDay=""
if "14:30:00" == "A" set startTime=""
set startDate=-s
echo startDate
shift
shift
shift
goto validate
)
-s -logpk cur -vendor -lp c:\xxx\testlogs
If called from cmd shortcut
EDIT3:
C:\test\>
if "-s" == "-s" (
set startDay=22.07.2014
set startTime=14:30:00
if "22.07.2014" == "a" set startDay=""
if "14:30:00" == "A" set startTime=""
set startDate=-s 22.07.2014 14:30:00
echo startDate -s 22.07.2014 14:30:00
shift
shift
shift
goto validate
)
-s 22.07.2014 14:30:00 -logpk cur -vendor -lp c:\xxx\testlogs
If called from opened cmd
you are running into the infamous early variable expansion problem. your variables are replaced with their values at the start of the block. since at that time startday and starttime are empty, this is what you get.
i suspect that in your testing from the command line, the variables are already set from the first try (they remain in the environment, you can see it with set).
the way around that is putting setlocal enabledelayedexpansion at the beginning of your batch file, and then reference your variables with !startday! instead of %startday%.
Can someone tell me what I am doing wrong with set flag1.. i am getting an error of flag1: Undefined variable.
if($notLoaded1 > 0) then
echo "Rows not loaded due to data errors in first load: $notLoaded1"
set flag1=1
endif
if($notLoaded2 > 0) then
echo "Rows not loaded due to data errors in second load: $notLoaded2"
set flag2=1
endif
if($notLoaded3 > 0) then
echo "Rows not loaded due to data errors in third load: $notLoaded3"
set flag3=1
endif
echo $flag1
echo $flag2
echo $flag3
is there a way to check all three of them in one if statement or rather than using 3 if statements
if ($flag1 > 0) then
exit 1
endif
if ($flag2 > 0) then
exit 1
endif
if ($flag3 > 0) then
exit 1
endif
Thank you
What do you need 3 flag variables for?
set error=0
if ($notLoaded1 > 0) then
echo "Rows not loaded due to data errors in first load: $notLoaded1"
set error=1
endif
if ($notLoaded2 > 0) then
echo "Rows not loaded due to data errors in second load: $notLoaded2"
set error=1
endif
if ($notLoaded3 > 0) then
echo "Rows not loaded due to data errors in third load: $notLoaded3"
set error=1
endif
if ($error) then
exit 1
endif
flag1 only gets set if $notLoaded1 is greater than 0. So if it's zero, you don't get a $flag1.
I'd suggest initializing those three variables with defaults beforehand:
set flag1=0
if (...) the
set flag1=1
echo 'Rows not loaded...'
endif
That'll guarantee that flag1 always exists.